Various smaller retraction related fixes and improvements
This commit is contained in:
parent
53df5d6b49
commit
13ffe5a667
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "converse.js",
|
||||
"version": "5.0.4",
|
||||
"version": "6.0.0",
|
||||
"description": "Browser based XMPP chat client",
|
||||
"browser": "dist/converse.js",
|
||||
"module": "src/converse.js",
|
||||
|
@ -247,7 +247,7 @@ converse.plugins.add('converse-message-view', {
|
||||
const is_own_message = this.model.get('sender') === 'me';
|
||||
const chatbox = this.model.collection.chatbox;
|
||||
const may_retract_own_message = is_own_message && ['all', 'own'].includes(_converse.allow_message_retraction);
|
||||
const may_moderate_message = is_groupchat &&
|
||||
const may_moderate_message = !is_own_message && is_groupchat &&
|
||||
['all', 'moderator'].includes(_converse.allow_message_retraction) &&
|
||||
await chatbox.canRetractMessages();
|
||||
|
||||
@ -306,11 +306,8 @@ converse.plugins.add('converse-message-view', {
|
||||
},
|
||||
|
||||
getRetractionText () {
|
||||
const username = this.model.getDisplayName();
|
||||
let retraction_text = __('%1$s has retracted this message', username);
|
||||
if (this.model.get('type') === 'groupchat') {
|
||||
if (this.model.get('type') === 'groupchat' && this.model.get('moderated_by')) {
|
||||
const retracted_by_mod = this.model.get('moderated_by');
|
||||
if (retracted_by_mod) {
|
||||
const chatbox = this.model.collection.chatbox;
|
||||
if (!this.model.mod) {
|
||||
this.model.mod =
|
||||
@ -318,10 +315,10 @@ converse.plugins.add('converse-message-view', {
|
||||
chatbox.occupants.findOccupant({'nick': Strophe.getResourceFromJid(retracted_by_mod)});
|
||||
}
|
||||
const modname = this.model.mod ? this.model.mod.getDisplayName() : 'A moderator';
|
||||
retraction_text = __('%1$s has retracted this message from %2$s', modname , username);
|
||||
return __('%1$s has retracted this message', modname);
|
||||
} else {
|
||||
return __('%1$s has retracted this message', this.model.getDisplayName());
|
||||
}
|
||||
}
|
||||
return retraction_text;
|
||||
},
|
||||
|
||||
renderErrorMessage () {
|
||||
|
@ -582,7 +582,7 @@ converse.plugins.add('converse-chat', {
|
||||
* whether a message was retracted or not.
|
||||
*/
|
||||
handleRetraction (attrs) {
|
||||
const RETRACTION_ATTRIBUTES = ['retracted', 'retracted_id'];
|
||||
const RETRACTION_ATTRIBUTES = ['retracted', 'retracted_id', 'editable'];
|
||||
if (attrs.retracted) {
|
||||
if (attrs.is_tombstone) {
|
||||
return false;
|
||||
@ -877,7 +877,7 @@ converse.plugins.add('converse-chat', {
|
||||
return;
|
||||
}
|
||||
if (_converse.allow_message_corrections === 'all') {
|
||||
attrs.editable = !(attrs.file || 'oob_url' in attrs);
|
||||
attrs.editable = !(attrs.file || attrs.retracted || 'oob_url' in attrs);
|
||||
} else if ((_converse.allow_message_corrections === 'last') &&
|
||||
(send_time > this.get('time_sent'))) {
|
||||
this.set({'time_sent': send_time});
|
||||
@ -885,7 +885,7 @@ converse.plugins.add('converse-chat', {
|
||||
if (msg) {
|
||||
msg.save({'editable': false});
|
||||
}
|
||||
attrs.editable = !(attrs.file || 'oob_url' in attrs);
|
||||
attrs.editable = !(attrs.file || attrs.retracted || 'oob_url' in attrs);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
* @description
|
||||
* Implements the non-view logic for XEP-0045 Multi-User Chat
|
||||
*/
|
||||
import "./converse-chat";
|
||||
import "./converse-disco";
|
||||
import "./converse-emoji";
|
||||
import { clone, get, intersection, invoke, isElement, isObject, isString, pick, uniq, zipObject } from "lodash";
|
||||
|
@ -130,6 +130,7 @@ const stanza_utils = {
|
||||
const delay = sizzle(`delay[xmlns="${Strophe.NS.DELAY}"]`, original_stanza).pop();
|
||||
const time = delay ? dayjs(delay.getAttribute('stamp')).toISOString() : (new Date()).toISOString();
|
||||
return {
|
||||
'editable': false,
|
||||
'retracted': time,
|
||||
'retracted_id': applies_to_id
|
||||
}
|
||||
@ -138,8 +139,9 @@ const stanza_utils = {
|
||||
const tombstone = sizzle(`> retracted[xmlns="${Strophe.NS.RETRACT}"]`, stanza).pop();
|
||||
if (tombstone) {
|
||||
return {
|
||||
'retracted': tombstone.getAttribute('stamp'),
|
||||
'is_tombstone': true
|
||||
'editable': false,
|
||||
'is_tombstone': true,
|
||||
'retracted': tombstone.getAttribute('stamp')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user