Commit 2d44144b authored by Christoph Scholz's avatar Christoph Scholz Committed by JC Brand

prevent message correction for files

parent cf94a2c0
# Changelog # Changelog
## 5.0.5
- Prevent editing of sent file uploads.
## 5.0.4 (2019-10-08) ## 5.0.4 (2019-10-08)
- New config option [allow_message_corrections](https://conversejs.org/docs/html/configuration.html#allow_message_corrections) - New config option [allow_message_corrections](https://conversejs.org/docs/html/configuration.html#allow_message_corrections)
......
...@@ -954,7 +954,7 @@ converse.plugins.add('converse-chatview', { ...@@ -954,7 +954,7 @@ converse.plugins.add('converse-chatview', {
while (idx < this.model.messages.length-1) { while (idx < this.model.messages.length-1) {
idx += 1; idx += 1;
const candidate = this.model.messages.at(idx); const candidate = this.model.messages.at(idx);
if (candidate.get('sender') === 'me' && candidate.get('message')) { if (candidate.get('editable')) {
message = candidate; message = candidate;
break; break;
} }
...@@ -982,7 +982,7 @@ converse.plugins.add('converse-chatview', { ...@@ -982,7 +982,7 @@ converse.plugins.add('converse-chatview', {
} }
} }
} }
message = message || this.getOwnMessages().reverse().find(m => m.get('message')); message = message || this.getOwnMessages().reverse().find(m => m.get('editable'));
if (message) { if (message) {
this.insertIntoTextArea(message.get('message'), true, true); this.insertIntoTextArea(message.get('message'), true, true);
message.save('correcting', true); message.save('correcting', true);
......
...@@ -785,7 +785,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -785,7 +785,7 @@ converse.plugins.add('converse-chatboxes', {
return; return;
} }
if (_converse.allow_message_corrections === 'all') { if (_converse.allow_message_corrections === 'all') {
attrs.editable = true; attrs.editable = !(attrs.file || 'oob_url' in attrs);
} else if ((_converse.allow_message_corrections === 'last') && } else if ((_converse.allow_message_corrections === 'last') &&
(send_time > this.get('time_sent'))) { (send_time > this.get('time_sent'))) {
this.set({'time_sent': send_time}); this.set({'time_sent': send_time});
...@@ -793,7 +793,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -793,7 +793,7 @@ converse.plugins.add('converse-chatboxes', {
if (msg) { if (msg) {
msg.save({'editable': false}); msg.save({'editable': false});
} }
attrs.editable = true; attrs.editable = !(attrs.file || 'oob_url' in attrs);
} }
}, },
...@@ -889,14 +889,14 @@ converse.plugins.add('converse-chatboxes', { ...@@ -889,14 +889,14 @@ converse.plugins.add('converse-chatboxes', {
'ephemeral': true 'ephemeral': true
}); });
} else { } else {
const message = this.messages.create( const attrs = Object.assign(
Object.assign(
this.getOutgoingMessageAttributes(), { this.getOutgoingMessageAttributes(), {
'file': true, 'file': true,
'progress': 0, 'progress': 0,
'slot_request_url': slot_request_url 'slot_request_url': slot_request_url
}), {'silent': true} });
); this.setEditable(attrs, (new Date()).toISOString());
const message = this.messages.create(attrs, {'silent': true});
message.file = file; message.file = file;
this.messages.trigger('add', message); this.messages.trigger('add', message);
message.getRequestSlotURL(); message.getRequestSlotURL();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment