modools: Restrict which affiliations and roles can be set

bsaed on `muc_disable_slash_commands`
This commit is contained in:
JC Brand 2020-02-21 13:21:25 +01:00
parent cd442f27c4
commit a1a2b501ee

View File

@ -1442,7 +1442,12 @@ converse.plugins.add('converse-muc-views', {
allowed_commands = allowed_commands.concat(VISITOR_COMMANDS); allowed_commands = allowed_commands.concat(VISITOR_COMMANDS);
} }
allowed_commands.sort(); allowed_commands.sort();
return allowed_commands;
if (Array.isArray(_converse.muc_disable_slash_commands)) {
return allowed_commands.filter(c => !_converse.muc_disable_slash_commands.includes(c));
} else {
return allowed_commands;
}
}, },
parseMessageForCommands (text) { parseMessageForCommands (text) {
@ -1455,14 +1460,8 @@ converse.plugins.add('converse-muc-views', {
return false; return false;
} }
const args = text.slice(('/'+command).length+1).trim(); const args = text.slice(('/'+command).length+1).trim();
const disabled_commands = Array.isArray(_converse.muc_disable_slash_commands) ?
let disabled_commands = []; _converse.muc_disable_slash_commands : [];
if (Array.isArray(_converse.muc_disable_slash_commands)) {
disabled_commands = _converse.muc_disable_slash_commands;
if (disabled_commands.includes(command)) {
return false;
}
}
const allowed_commands = this.getAllowedCommands(); const allowed_commands = this.getAllowedCommands();
if (!allowed_commands.includes(command)) { if (!allowed_commands.includes(command)) {
return false; return false;