Commit 90ef4b0c authored by JC Brand's avatar JC Brand

Don't let non-mods open the modtools modal

Bugfix: fall back to nick if the JID is not available.
parent 768ed4a5
......@@ -2987,9 +2987,9 @@
textarea.value = '/help';
view.onKeyDown(enter);
info_messages = sizzle('.chat-info', view.el).slice(1);
expect(info_messages.length).toBe(10);
expect(info_messages.length).toBe(11);
commands = info_messages.map(m => m.textContent.replace(/:.*$/, ''));
expect(commands).toEqual(["/clear", "/help", "/kick", "/me", "/mute", "/nick", "/register", "/subject", "/topic", "/voice"]);
expect(commands).toEqual(["/clear", "/help", "/kick", "/me", "/modtools", "/mute", "/nick", "/register", "/subject", "/topic", "/voice"]);
occupant.set('role', 'participant');
textarea.value = '/clear';
......
......@@ -50,8 +50,8 @@ const ROLES = ['moderator', 'participant', 'visitor'];
const AFFILIATIONS = ['admin', 'member', 'outcast', 'owner'];
const AFFILIATION_CHANGE_COMANDS = ['admin', 'ban', 'owner', 'member', 'revoke'];
const OWNER_COMMANDS = ['owner'];
const ADMIN_COMMANDS = ['admin', 'ban', 'deop', 'destroy', 'modtools', 'member', 'op', 'revoke'];
const MODERATOR_COMMANDS = ['kick', 'mute', 'voice'];
const ADMIN_COMMANDS = ['admin', 'ban', 'deop', 'destroy', 'member', 'op', 'revoke'];
const MODERATOR_COMMANDS = ['kick', 'mute', 'voice', 'modtools'];
const VISITOR_COMMANDS = ['nick'];
const COMMAND_TO_ROLE = {
......@@ -349,8 +349,7 @@ converse.plugins.add('converse-muc-views', {
ev.stopPropagation();
ev.preventDefault();
const data = new FormData(ev.target);
const jid = data.get('jid');
const occupant = this.chatroomview.model.getOccupant(jid);
const occupant = this.chatroomview.model.getOccupant(data.get('jid') || data.get('nick'));
const role = data.get('role');
const reason = data.get('reason');
const current_role = this.model.get('role');
......@@ -365,8 +364,10 @@ converse.plugins.add('converse-muc-views', {
this.alert(__('You\'re not allowed to make that change'), 'danger');
} else {
this.alert(__('Sorry, something went wrong while trying to set the role'), 'danger');
if (u.isErrorObject(e)) {
_converse.log(e, Strophe.LogLevel.ERROR);
}
}
_converse.log(e, Strophe.LogLevel.ERROR);
}
);
}
......@@ -762,6 +763,9 @@ converse.plugins.add('converse-muc-views', {
},
showModeratorToolsModal (affiliation) {
if (!this.verifyRoles(['moderator'])) {
return;
}
if (_.isUndefined(this.model.modtools_modal)) {
const model = new Backbone.Model({'affiliation': affiliation});
this.modtools_modal = new _converse.ModeratorToolsModal({'model': model, 'chatroomview': 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