Skip to content

Commit

Permalink
Fix modchat permission check
Browse files Browse the repository at this point in the history
It was interacting badly with the new code to give drivers moderator
permissions in battles.
  • Loading branch information
Zarel committed Aug 5, 2019
1 parent 9423ce9 commit 00184f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/chat-plugins/roomsettings.js
Expand Up @@ -270,7 +270,7 @@ exports.commands = {
const modchatSetting = Chat.escapeHTML(room.modchat);
this.add(`|raw|<div class="broadcast-red"><strong>Moderated chat was set to ${modchatSetting}!</strong><br />Only users of rank ${modchatSetting} and higher can talk.</div>`);
}
if (room.battle && !room.modchat && !user.can('modchat')) room.requestModchat(null);
if (room.requestModchat && !room.modchat) room.requestModchat(null);
this.privateModAction(`(${user.name} set modchat to ${room.modchat})`);
this.modlog('MODCHAT', null, `to ${room.modchat}`);

Expand Down
8 changes: 4 additions & 4 deletions server/rooms.js
Expand Up @@ -1545,17 +1545,17 @@ class GameRoom extends BasicChatRoom {
return this.game['p' + (num + 1)];
}
/**
* @param {User} user
* @param {User | null} user
*/
requestModchat(user) {
if (user === null) {
if (!user) {
this.modchatUser = '';
return;
} else if (user.can('modchat') || !this.modchatUser || this.modchatUser === user.userid) {
} else if (!this.modchatUser || this.modchatUser === user.userid || this.getAuth(user) !== Users.PLAYER_SYMBOL) {
this.modchatUser = user.userid;
return;
} else {
return "Invite-only can only be turned off by the user who turned it on, or staff";
return "Modchat can only be changed by the user who turned it on, or by staff";
}
}
/**
Expand Down

0 comments on commit 00184f6

Please sign in to comment.