Add new config option allow_message_retractions

This commit is contained in:
JC Brand 2019-11-22 12:55:15 +01:00
parent 2eff75b387
commit e4010185dc
3 changed files with 37 additions and 16 deletions

View File

@ -10,8 +10,9 @@
To add custom emojis, edit the `emojis.json` file.
- Refactor some presence and status handling code from `converse-core` into `@converse/headless/converse-status`.
- New API [\_converse.api.headlines](https://conversejs.org/docs/html/api/-_converse.api.headlines.html#.get)
- New config option [muc_mention_autocomplete_filter](https://conversejs.org/docs/html/configuration.html#muc_mention_autocomplete_filter)
- New config option [muc_mention_autocomplete_show_avatar](https://conversejs.org/docs/html/configuration.html#muc_mention_autocomplete_show_avatar)
- New config option [muc-mention-autocomplete-filter](https://conversejs.org/docs/html/configuration.html#muc-mention-autocomplete-filter)
- New config option [muc-mention-autocomplete-show-avatar](https://conversejs.org/docs/html/configuration.html#muc-mention-autocomplete-show-avatar)
- New config option [allow_message_retraction](https://conversejs.org/docs/html/configuration.html#allow-message-retraction)
- #129: Add support for XEP-0156: Disovering Alternative XMPP Connection Methods. Only XML is supported for now.
- #1105: Preliminary support for storing persistent data in IndexedDB instead of localStorage

View File

@ -149,6 +149,32 @@ allow_logout
Determines whether the user is allowed to log out. If set to ``false``, there will be no logout button.
.. _`allow_message_corrections`:
allow_message_corrections
-------------------------
* Default: ``'all'``
* Possible values: ``'all'``, ``'last'``
Configures the last message correction (LMC) feature of Converse. By default you can edit all of your own
messages. Setting this to ``'last'`` will limit this feature to the message sent most recently as suggested by
`XEP-0308: Last Message Correction <https://xmpp.org/extensions/xep-0308.html>`_.
Setting it to anything else (including ``false``) will disable the ability to correct sent messages.
allow_message_retraction
------------------------
* Default: ``'all'``
* Possible values: ``'all'``, ``'own'``, ``'moderator'``
Determines who is allowed to retract messages. If set to ``'all'``, then normal
users may retract their own messages and ``'moderators'`` may retract the messages of
other users.
allow_muc
---------
@ -858,18 +884,6 @@ keepalive
Determines whether Converse will attempt to keep you logged in across page loads.
.. _`allow_message_corrections`:
allow_message_corrections
-------------------------
* Default: ``'all'``
Configures the last message correction (LMC) feature of Converse. By default you can edit all of your own
messages. Setting this to ``'last'`` will limit this feature to the message sent most recently as suggested by
`XEP-0308: Last Message Correction <https://xmpp.org/extensions/xep-0308.html>`_.
Setting it to anything else (including ``false``) will disable the ability to correct sent messages.
.. _`locales`:
locales

View File

@ -68,7 +68,8 @@ converse.plugins.add('converse-message-view', {
_converse.api.settings.update({
'show_images_inline': true
'show_images_inline': true,
'allow_message_retraction': 'all'
});
_converse.MessageVersionsModal = _converse.BootstrapModal.extend({
@ -245,7 +246,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 retractable= !is_retracted && (is_groupchat? await chatbox.canRetractMessages() : is_own_message);
const may_retract_own_message = is_own_message && ['all', 'own'].includes(_converse.allow_message_retraction);
const may_moderate_message = is_groupchat &&
['all', 'moderator'].includes(_converse.allow_message_retraction) &&
await chatbox.canRetractMessages();
const retractable= !is_retracted && (may_moderate_message || may_retract_own_message);
const msg = u.stringToElement(tpl_message(
Object.assign(
this.model.toJSON(), {