Commit 41318504 authored by JC Brand's avatar JC Brand

Allow setting of affiliation on JID of user not in the MUC

parent 6426f9cf
...@@ -1363,6 +1363,9 @@ converse.plugins.add('converse-muc-views', { ...@@ -1363,6 +1363,9 @@ converse.plugins.add('converse-muc-views', {
}, },
getNickOrJIDFromCommandArgs (args) { getNickOrJIDFromCommandArgs (args) {
if (u.isValidJID(args.trim())) {
return args.trim();
}
if (!args.startsWith('@')) { if (!args.startsWith('@')) {
args = '@'+ args; args = '@'+ args;
} }
...@@ -1399,21 +1402,25 @@ converse.plugins.add('converse-muc-views', { ...@@ -1399,21 +1402,25 @@ converse.plugins.add('converse-muc-views', {
if (!nick_or_jid) { if (!nick_or_jid) {
return false; return false;
} }
let jid;
const reason = args.split(nick_or_jid, 2)[1].trim(); const reason = args.split(nick_or_jid, 2)[1].trim();
const occupant = this.model.getOccupant(nick_or_jid); const occupant = this.model.getOccupant(nick_or_jid);
if (!occupant) { if (occupant) {
this.showErrorMessage(__( jid = occupant.get('jid');
"Couldn't find a participant with that nickname or XMPP address. "+ } else {
"They might have left the groupchat." if (u.isValidJID(nick_or_jid)) {
)); jid = nick_or_jid;
return; } else {
} this.showErrorMessage(__(
"Couldn't find a participant with that nickname. "+
const attrs = { "They might have left the groupchat."
'jid': occupant.get('jid'), ));
'reason': reason return;
}
} }
if (_converse.auto_register_muc_nickname && occupant) { const attrs = { jid, reason };
if (occupant && _converse.auto_register_muc_nickname) {
attrs['nick'] = occupant.get('nick'); attrs['nick'] = occupant.get('nick');
} }
this.model.setAffiliation(affiliation, [attrs]) this.model.setAffiliation(affiliation, [attrs])
......
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