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

prevent message correction for files

parent cf94a2c0
# Changelog
## 5.0.5
- Prevent editing of sent file uploads.
## 5.0.4 (2019-10-08)
- 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', {
while (idx < this.model.messages.length-1) {
idx += 1;
const candidate = this.model.messages.at(idx);
if (candidate.get('sender') === 'me' && candidate.get('message')) {
if (candidate.get('editable')) {
message = candidate;
break;
}
......@@ -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) {
this.insertIntoTextArea(message.get('message'), true, true);
message.save('correcting', true);
......
......@@ -785,7 +785,7 @@ converse.plugins.add('converse-chatboxes', {
return;
}
if (_converse.allow_message_corrections === 'all') {
attrs.editable = true;
attrs.editable = !(attrs.file || 'oob_url' in attrs);
} else if ((_converse.allow_message_corrections === 'last') &&
(send_time > this.get('time_sent'))) {
this.set({'time_sent': send_time});
......@@ -793,7 +793,7 @@ converse.plugins.add('converse-chatboxes', {
if (msg) {
msg.save({'editable': false});
}
attrs.editable = true;
attrs.editable = !(attrs.file || 'oob_url' in attrs);
}
},
......@@ -889,14 +889,14 @@ converse.plugins.add('converse-chatboxes', {
'ephemeral': true
});
} else {
const message = this.messages.create(
Object.assign(
this.getOutgoingMessageAttributes(), {
'file': true,
'progress': 0,
'slot_request_url': slot_request_url
}), {'silent': true}
);
const attrs = Object.assign(
this.getOutgoingMessageAttributes(), {
'file': true,
'progress': 0,
'slot_request_url': slot_request_url
});
this.setEditable(attrs, (new Date()).toISOString());
const message = this.messages.create(attrs, {'silent': true});
message.file = file;
this.messages.trigger('add', message);
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