New config option clear_messages_on_reconnection

In some cases, it might be desirable to clear cached chat messages once you've
reconnected to the XMPP server.

For example, if you want to prevent the chat history from getting too long or
if you want to avoid gaps in the chat history (for example due to MAM not
returning all messages since the last cached message).

If you're using OMEMO, then you probably don't want to set this setting to
``true``. OMEMO messages can be decrypted only once, so if they then
subsequently get cleared, you won't get the plaintext back.
This commit is contained in:
JC Brand 2019-07-03 11:55:42 +02:00
parent 67bcc00f10
commit da1d87648c
4 changed files with 28 additions and 4 deletions

View File

@ -18,14 +18,15 @@
- Continuously retry (in 2s intervals) to fetch login credentials (via [credentials_url](https://conversejs.org/docs/html/configuration.html#credentials-url)) in case of failure
- Replace `moment` with [DayJS](https://github.com/iamkun/dayjs).
- New config option [auto_focus](https://conversejs.org/docs/html/configuration.html#auto-focus)
- New config option [clear_messages_on_reconnection](https://conversejs.org/docs/html/configuration.html#clear-messages-on-reconnection)
- New config option [enable_smacks](https://conversejs.org/docs/html/configuration.html#enable-smacks)
- New config option [muc_show_join_leave_status](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave-status)
- New config option [message_limit](https://conversejs.org/docs/html/configuration.html#message-limit)
- New config option [muc_mention_autocomplete_min_chars](https://conversejs.org/docs/html/configuration.html#muc-mention-autocomplete-min-chars)
- New config option [muc_show_join_leave_status](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave-status)
- New config option [singleton](https://conversejs.org/docs/html/configuration.html#singleton)
By setting this option to `false` and `view_mode` to `'embedded'`, it's now possible to
"embed" the full app and not just a single chat. To embed just a single chat, it's now
necessary to explicitly set `singleton` to `true`.
- New config option [muc_mention_autocomplete_min_chars](https://conversejs.org/docs/html/configuration.html#muc-mention-autocomplete-min-chars)
- New event: [chatBoxBlurred](https://conversejs.org/docs/html/api/-_converse.html#event:chatBoxBlurred)
- New event: [chatReconnected](https://conversejs.org/docs/html/api/-_converse.html#event:chatReconnected)
- #316: Add support for XEP-0198 Stream Management

View File

@ -468,6 +468,24 @@ For more information, read this blog post: `Which BOSH server do you need? <http
A more modern alternative to BOSH is to use `websockets <https://developer.mozilla.org/en/docs/WebSockets>`_.
Please see the :ref:`websocket-url` configuration setting.
clear_messages_on_reconnection
------------------------------
* Default: ``false``
In some cases, it might be desirable to clear cached chat messages once you've
reconnected to the XMPP server.
For example, if you want to prevent the chat history from getting too long or
if you want to avoid gaps in the chat history (for example due to MAM not
returning all messages since the last cached message).
Beware, if you're using OMEMO, then you probably don't want to set this setting to
``true``. OMEMO messages can be decrypted only once, so if they then
subsequently get cleared, you won't get the plaintext back.
chatstate_notification_blacklist
--------------------------------

View File

@ -36,6 +36,7 @@ converse.plugins.add('converse-chatboxes', {
// configuration settings.
_converse.api.settings.update({
'auto_join_private_chats': [],
'clear_messages_on_reconnection': false,
'filter_by_resource': false,
'send_chat_state_notifications': true
});
@ -358,7 +359,9 @@ converse.plugins.add('converse-chatboxes', {
},
onReconnection () {
if (_converse.clear_messages_on_reconnection) {
this.clearMessages();
}
this.announceReconnection();
},

View File

@ -398,7 +398,9 @@ converse.plugins.add('converse-muc', {
// the cache (which might be stale).
this.removeNonMembers();
await this.refreshRoomFeatures();
this.clearMessages(); // XXX: This should be conditional
if (_converse.clear_messages_on_reconnection) {
this.clearMessages();
}
if (!u.isPersistableModel(this)) {
// XXX: Happens during tests, nothing to do if this
// is a hanging chatbox (i.e. not in the collection anymore).