Commit fcc9e8c3 authored by JC Brand's avatar JC Brand

Also allow `@` in moderator commands

parent be0274f1
...@@ -3191,7 +3191,7 @@ ...@@ -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);
......
...@@ -921,7 +921,10 @@ converse.plugins.add('converse-muc-views', { ...@@ -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', { ...@@ -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', { ...@@ -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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment