Ver Fonte

Clear message cache when closing a MUC

JC Brand há 4 anos atrás
pai
commit
14c9b2f4ae

+ 3 - 0
CHANGES.md

@@ -9,10 +9,13 @@
 - New hook: [getMessageActionButtons](https://conversejs.org/docs/html/api/-_converse.html#event:getMessageActionButtons)
 - New hook: [getMessageActionButtons](https://conversejs.org/docs/html/api/-_converse.html#event:getMessageActionButtons)
 - File structure reordering: All plugins are now in `./plugins` folders.
 - File structure reordering: All plugins are now in `./plugins` folders.
 - New configuration setting: [show_tab_notifications](https://conversejs.org/docs/html/configuration.html#show-tab-notifications)
 - New configuration setting: [show_tab_notifications](https://conversejs.org/docs/html/configuration.html#show-tab-notifications)
+- New configuration setting: [muc_clear_messages_on_leave](https://conversejs.org/docs/html/configuration.html#muc-clear-messages-on-leave)
 
 
 ### Breaking Changes
 ### Breaking Changes
 
 
 The [afterMessageBodyTransformed](https://conversejs.org/docs/html/api/-_converse.html#event:afterMessageBodyTransformed) and [beforeMessageBodyTransformed](https://conversejs.org/docs/html/api/-_converse.html#event:beforeMessageBodyTransformed) events now has a different signatures.
 The [afterMessageBodyTransformed](https://conversejs.org/docs/html/api/-_converse.html#event:afterMessageBodyTransformed) and [beforeMessageBodyTransformed](https://conversejs.org/docs/html/api/-_converse.html#event:beforeMessageBodyTransformed) events now has a different signatures.
+When leaving a MUC, the message history is deleted. This means that decrypted
+OMEMO messages are gone and cannot be recovered on that device. See [muc_clear_messages_on_leave](https://conversejs.org/docs/html/configuration.html#muc-clear-messages-on-leave).
 
 
 ## 7.0.2 (2020-11-23)
 ## 7.0.2 (2020-11-23)
 
 

+ 12 - 2
docs/source/configuration.rst

@@ -1072,7 +1072,7 @@ VCard is taken, and if that is not set but `muc_nickname_from_jid`_ is set to
 If no nickame value is found, then an error will be raised.
 If no nickame value is found, then an error will be raised.
 
 
 muc_hats
 muc_hats
--------------------
+--------
 
 
 * Default: ``['xep317']``
 * Default: ``['xep317']``
 
 
@@ -1197,6 +1197,16 @@ If all roles or all affiliations are disabled, then the relevant tab won't be
 showed at all.
 showed at all.
 
 
 
 
+muc_clear_messages_on_leave
+---------------------------
+
+* Default: ``true``
+
+Starting with Converse 8.0.0, when leaving a MUC, all cached messages in the history is cleared.
+
+Note: This means that you lose your history of decrypted OMEMO messages and cannot recover it.
+
+
 muc_disable_slash_commands
 muc_disable_slash_commands
 --------------------------
 --------------------------
 
 
@@ -1383,7 +1393,7 @@ muc_show_info_messages
 ----------------------
 ----------------------
 
 
 * Default: List composed of MUC status codes, role changes, join and leave events
 * Default: List composed of MUC status codes, role changes, join and leave events
-and affiliation changes. The values of converse.MUC_INFO_CODES below are joined to 
+and affiliation changes. The values of converse.MUC_INFO_CODES below are joined to
 build the default list:
 build the default list:
 
 
 .. code-block:: javascript
 .. code-block:: javascript

+ 1 - 0
src/headless/plugins/muc/index.js

@@ -223,6 +223,7 @@ converse.plugins.add('converse-muc', {
             'auto_register_muc_nickname': false,
             'auto_register_muc_nickname': false,
             'hide_muc_participants': false,
             'hide_muc_participants': false,
             'locked_muc_domain': false,
             'locked_muc_domain': false,
+            'muc_clear_messages_on_leave': true,
             'muc_domain': undefined,
             'muc_domain': undefined,
             'muc_fetch_members': true,
             'muc_fetch_members': true,
             'muc_history_max_stanzas': undefined,
             'muc_history_max_stanzas': undefined,

+ 2 - 0
src/headless/plugins/muc/muc.js

@@ -632,6 +632,8 @@ const ChatRoomMixin = {
     async leave (exit_msg) {
     async leave (exit_msg) {
         this.features.destroy();
         this.features.destroy();
         this.occupants.clearStore();
         this.occupants.clearStore();
+        api.settings.get('muc_clear_messages_on_leave') && this.messages.clearStore();
+
         if (_converse.disco_entities) {
         if (_converse.disco_entities) {
             const disco_entity = _converse.disco_entities.get(this.get('jid'));
             const disco_entity = _converse.disco_entities.get(this.get('jid'));
             if (disco_entity) {
             if (disco_entity) {