Also allow @ in moderator commands

This commit is contained in:
JC Brand 2019-05-27 12:24:46 +02:00
parent be0274f1f0
commit fcc9e8c31b
2 changed files with 7 additions and 4 deletions

View File

@ -3191,7 +3191,7 @@
// XXX: Calling onFormSubmitted directly, trying // XXX: Calling onFormSubmitted directly, trying
// again via triggering Event doesn't work for some weird // again via triggering Event doesn't work for some weird
// reason. // reason.
textarea.value = '/kick annoying guy You\'re annoying'; textarea.value = '/kick @annoying guy You\'re annoying';
view.onFormSubmitted(new Event('submit')); view.onFormSubmitted(new Event('submit'));
expect(view.validateRoleOrAffiliationChangeArgs.calls.count()).toBe(2); expect(view.validateRoleOrAffiliationChangeArgs.calls.count()).toBe(2);

View File

@ -921,7 +921,10 @@ converse.plugins.add('converse-muc-views', {
}, },
getNickOrJIDFromCommandArgs (args) { getNickOrJIDFromCommandArgs (args) {
const [text, references] = this.model.parseTextForReferences('@'+args); if (!args.startsWith('@')) {
args = '@'+ args;
}
const [text, references] = this.model.parseTextForReferences(args);
if (!references.length) { if (!references.length) {
this.showErrorMessage(__("Error: couldn't find a groupchat participant based on your arguments")); this.showErrorMessage(__("Error: couldn't find a groupchat participant based on your arguments"));
return false; return false;
@ -944,7 +947,7 @@ converse.plugins.add('converse-muc-views', {
if (!nick_or_jid) { if (!nick_or_jid) {
return false; return false;
} }
const reason = args.slice(nick_or_jid.length).trim(); const reason = args.split(nick_or_jid, 2)[1].trim();
// We're guaranteed to have an occupant due to getNickOrJIDFromCommandArgs // We're guaranteed to have an occupant due to getNickOrJIDFromCommandArgs
const occupant = this.model.getOccupant(nick_or_jid); const occupant = this.model.getOccupant(nick_or_jid);
const attrs = { const attrs = {
@ -981,7 +984,7 @@ converse.plugins.add('converse-muc-views', {
if (!nick_or_jid) { if (!nick_or_jid) {
return false; return false;
} }
const reason = args.slice(nick_or_jid.length).trim(); const reason = args.split(nick_or_jid, 2)[1].trim();
// We're guaranteed to have an occupant due to getNickOrJIDFromCommandArgs // We're guaranteed to have an occupant due to getNickOrJIDFromCommandArgs
const occupant = this.model.getOccupant(nick_or_jid); const occupant = this.model.getOccupant(nick_or_jid);
this.model.setRole(occupant, role, reason, undefined, this.onCommandError.bind(this)); this.model.setRole(occupant, role, reason, undefined, this.onCommandError.bind(this));