From d0ddda82447e6152ca3b06610fe8ad0b5954cc5c Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 14 May 2019 13:01:07 +0200 Subject: [PATCH] New config option muc_show_disconnection_status --- CHANGES.md | 1 + docs/source/configuration.rst | 10 +++++++++ spec/muc.js | 38 +++++++++++++++++++++++++++++++++++ src/converse-muc-views.js | 3 ++- 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index aa2f20530..097282df1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ - 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 API method [\_converse.api.disco.features.get](https://conversejs.org/docs/html/api/-_converse.api.disco.features.html#.get) +- New config setting [muc_show_disconnection_status](https://conversejs.org/docs/html/configuration.html#muc-show-disconnection-status) - #1296: `embedded` view mode shows `chatbox-navback` arrow in header - #1465: When highlighting a roster contact, they're incorrectly shown as online - #1532: Converse reloads on enter pressed in the filter box diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index 0cf7fd0bf..55c04b309 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -1026,6 +1026,16 @@ all MUCs with set autojoin flag in their respective bookmarks will be joined on startup of Converse. When set to ``false`` no MUCs are automatically joined based on their bookmarks. +muc_show_disconnection_status +----------------------------- + +* Default; ``true`` + +Determines whether Converse shows the optionally included status message when a +user leaves the MUC. + +See https://xmpp.org/extensions/xep-0045.html#changepres + muc_show_join_leave ------------------- diff --git a/spec/muc.js b/spec/muc.js index 0739e8bf0..326e1d3ec 100644 --- a/spec/muc.js +++ b/spec/muc.js @@ -896,6 +896,44 @@ done(); })); + it("doesn't show the disconnection status when muc_show_disconnection_status is false", + mock.initConverse( + null, ['rosterGroupsFetched', 'chatBoxesFetched'], {'muc_show_disconnection_status': false}, + async function (done, _converse) { + + await test_utils.openChatRoom(_converse, "coven", 'chat.shakespeare.lit', 'some1'); + const view = _converse.chatboxviews.get('coven@chat.shakespeare.lit'); + const chat_content = view.el.querySelector('.chat-content'); + let presence = $pres({ + to: 'dummy@localhost/resource', + from: 'coven@chat.shakespeare.lit/newguy' + }).c('x', {xmlns: Strophe.NS.MUC_USER}) + .c('item', { + 'affiliation': 'none', + 'jid': 'newguy@localhost/_converse.js-290929789', + 'role': 'participant' + }); + _converse.connection._dataRecv(test_utils.createRequest(presence)); + expect(chat_content.querySelectorAll('div.chat-info').length).toBe(0); + + presence = $pres({ + to: 'dummy@localhost/resource', + type: 'unavailable', + from: 'coven@chat.shakespeare.lit/newguy' + }) + .c('status', 'Disconnected: Replaced by new connection').up() + .c('x', {xmlns: Strophe.NS.MUC_USER}) + .c('item', { + 'affiliation': 'none', + 'jid': 'newguy@localhost/_converse.js-290929789', + 'role': 'none' + }); + _converse.connection._dataRecv(test_utils.createRequest(presence)); + expect(chat_content.querySelectorAll('div.chat-info').length).toBe(1); + expect(sizzle('div.chat-info', chat_content).pop().textContent).toBe('newguy has left the groupchat'); + done(); + })); + it("role-change messages that follow a MUC leave are left out", mock.initConverse( null, ['rosterGroupsFetched', 'chatBoxesFetched'], {}, diff --git a/src/converse-muc-views.js b/src/converse-muc-views.js index 0da58533b..85395555f 100644 --- a/src/converse-muc-views.js +++ b/src/converse-muc-views.js @@ -117,6 +117,7 @@ converse.plugins.add('converse-muc-views', { 'locked_muc_nickname': false, 'muc_disable_slash_commands': false, 'muc_domain': undefined, + 'muc_show_disconnection_status': true, 'muc_show_join_leave': true, 'roomconfig_whitelist': [], 'visible_toolbar_buttons': { @@ -1651,7 +1652,7 @@ converse.plugins.add('converse-muc-views', { return; } const nick = occupant.get('nick'), - stat = occupant.get('status'), + stat = _converse.muc_show_disconnection_status ? occupant.get('status') : null, prev_info_el = this.getPreviousJoinOrLeaveNotification(this.content.lastElementChild, nick), dataset = _.get(prev_info_el, 'dataset', {});