diff --git a/CHANGES.md b/CHANGES.md index 2b947fe16..1c249679e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,9 @@ - #1296: `embedded` view mode shows `chatbox-navback` arrow in header - #1532: Converse reloads on enter pressed in the filter box +- **Breaking changes**: +- Rename `muc_disable_moderator_commands` to [muc_disable_slash_commands](https://conversejs.org/docs/html/configuration.html#muc-disable-slash-commands). + ### API changes - `_converse.chats.open` and `_converse.rooms.open` now take a `force` diff --git a/dist/converse.js b/dist/converse.js index b67d0be4d..9b096711a 100644 --- a/dist/converse.js +++ b/dist/converse.js @@ -53542,7 +53542,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins 'cache_muc_messages': true, 'locked_muc_domain': false, 'locked_muc_nickname': false, - 'muc_disable_moderator_commands': false, + 'muc_disable_slash_commands': false, 'muc_domain': undefined, 'muc_show_join_leave': true, 'roomconfig_whitelist': [], @@ -54457,14 +54457,14 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins }, parseMessageForCommands(text) { - if (_converse.muc_disable_moderator_commands && !_.isArray(_converse.muc_disable_moderator_commands)) { + if (_converse.muc_disable_slash_commands && !_.isArray(_converse.muc_disable_slash_commands)) { return _converse.ChatBoxView.prototype.parseMessageForCommands.apply(this, arguments); } const match = text.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false, '', ''], args = match[2] && match[2].splitOnce(' ').filter(s => s) || [], command = match[1].toLowerCase(), - disabled_commands = _.isArray(_converse.muc_disable_moderator_commands) ? _converse.muc_disable_moderator_commands : []; + disabled_commands = _.isArray(_converse.muc_disable_slash_commands) ? _converse.muc_disable_slash_commands : []; if (_.includes(disabled_commands, command)) { return false; diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index 40ec6ae7d..85dc45d26 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -966,8 +966,8 @@ Message carbons is the XEP (Jabber protocol extension) specifically drafted to solve this problem, while `forward_messages`_ uses `stanza forwarding `_ -muc_disable_moderator_commands ------------------------------- +muc_disable_slash_commands +-------------------------- * Default: ``false`` @@ -981,7 +981,7 @@ The following example will disable 'mute' and 'voice' command: .. code-block:: javascript - muc_disable_moderator_commands: ['mute', 'voice'], + muc_disable_slash_commands: ['mute', 'voice'], muc_domain ---------- diff --git a/spec/muc.js b/spec/muc.js index f724c3e0b..cb7e24f03 100644 --- a/spec/muc.js +++ b/spec/muc.js @@ -2619,21 +2619,21 @@ it("takes /help to show the available commands and commands can be disabled by config", mock.initConverse( - null, ['rosterGroupsFetched'], {muc_disable_moderator_commands: ['mute', 'voice']}, + null, ['rosterGroupsFetched'], {muc_disable_slash_commands: ['mute', 'voice']}, async function (done, _converse) { await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy'); const view = _converse.chatboxviews.get('lounge@localhost'); var textarea = view.el.querySelector('.chat-textarea'); - textarea.value = '/help This is the groupchat subject'; - view.keyPressed({ - target: textarea, - preventDefault: _.noop, - keyCode: 13 - }); + const enter = { 'target': textarea, 'preventDefault': _.noop, 'keyCode': 13 }; + spyOn(window, 'confirm').and.callFake(() => true); + textarea.value = '/clear'; + view.keyPressed(enter); + textarea.value = '/help'; + view.keyPressed(enter); const info_messages = Array.prototype.slice.call(view.el.querySelectorAll('.chat-info'), 0); - expect(info_messages.length).toBe(18); + expect(info_messages.length).toBe(17); expect(info_messages.pop().textContent).toBe('/topic: Set groupchat subject (alias for /subject)'); expect(info_messages.pop().textContent).toBe('/subject: Set groupchat subject'); expect(info_messages.pop().textContent).toBe('/revoke: Revoke user\'s membership'); diff --git a/src/converse-muc-views.js b/src/converse-muc-views.js index 84bb5a006..7aa6c76b6 100644 --- a/src/converse-muc-views.js +++ b/src/converse-muc-views.js @@ -115,7 +115,7 @@ converse.plugins.add('converse-muc-views', { 'cache_muc_messages': true, 'locked_muc_domain': false, 'locked_muc_nickname': false, - 'muc_disable_moderator_commands': false, + 'muc_disable_slash_commands': false, 'muc_domain': undefined, 'muc_show_join_leave': true, 'roomconfig_whitelist': [], @@ -937,15 +937,15 @@ converse.plugins.add('converse-muc-views', { }, parseMessageForCommands (text) { - if (_converse.muc_disable_moderator_commands && - !_.isArray(_converse.muc_disable_moderator_commands)) { + if (_converse.muc_disable_slash_commands && + !_.isArray(_converse.muc_disable_slash_commands)) { return _converse.ChatBoxView.prototype.parseMessageForCommands.apply(this, arguments); } const match = text.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false, '', ''], args = match[2] && match[2].splitOnce(' ').filter(s => s) || [], command = match[1].toLowerCase(), - disabled_commands = _.isArray(_converse.muc_disable_moderator_commands) ? - _converse.muc_disable_moderator_commands : []; + disabled_commands = _.isArray(_converse.muc_disable_slash_commands) ? + _converse.muc_disable_slash_commands : []; if (_.includes(disabled_commands, command)) { return false; }