Rename `muc_disable_moderator_commands` to `muc_disable_slash_commands`

Since those commands aren't only about moderation
This commit is contained in:
JC Brand 2019-04-25 10:59:16 +02:00
parent c72dc74022
commit dedede56f8
5 changed files with 22 additions and 19 deletions

View File

@ -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`

6
dist/converse.js vendored
View File

@ -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;

View File

@ -966,8 +966,8 @@ Message carbons is the XEP (Jabber protocol extension) specifically drafted to
solve this problem, while `forward_messages`_ uses
`stanza forwarding <http://www.xmpp.org/extensions/xep-0297.html>`_
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
----------

View File

@ -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');

View File

@ -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;
}