Commit 366dee0a authored by JC Brand's avatar JC Brand

Bugfix. Allow moderators to retract their own messages

parent a7f28cd6
......@@ -234,13 +234,13 @@
height: var(--message-font-size);
font-size: var(--message-font-size);
padding: 0;
padding-left: 0.75em;
margin-left: 0.75em;
border: none;
opacity: 0;
background: transparent;
cursor: pointer;
&:focus {
display: block;
opacity: 1;
}
}
}
......
......@@ -533,7 +533,7 @@
await view.model.queueMessage(received_stanza);
await u.waitUntil(() => view.el.querySelector('.chat-msg__content'));
expect(view.el.querySelector('.chat-msg__content .chat-msg__action-retract')).toBe(null);
const result = await view.model.canRetractMessages();
const result = await view.model.canModerateMessages();
expect(result).toBe(false);
done();
}));
......
......@@ -234,10 +234,12 @@ converse.plugins.add('converse-message-view', {
const is_groupchat = this.model.get('type') === 'groupchat';
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_retract_own_message = is_own_message && (
['all', 'own'].includes(_converse.allow_message_retraction) || await chatbox.canModerateMessages()
);
const may_moderate_message = !is_own_message && is_groupchat &&
['all', 'moderator'].includes(_converse.allow_message_retraction) &&
await chatbox.canRetractMessages();
await chatbox.canModerateMessages();
const retractable= !is_retracted && (may_moderate_message || may_retract_own_message);
const msg = u.stringToElement(tpl_message(
......
......@@ -820,7 +820,7 @@ converse.plugins.add('converse-muc', {
return _converse.ChatBox.prototype.close.call(this);
},
canRetractMessages () {
canModerateMessages () {
const self = this.getOwnOccupant();
return self && self.isModerator() && _converse.api.disco.supports(Strophe.NS.MODERATE, this.get('jid'));
},
......
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