From 056f98604aa99f778b89a4487be6267c42fe7afd Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sat, 17 Dec 2022 00:15:07 +0100 Subject: [PATCH] Simplify checking for privileged user messages. --- static/galene.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/static/galene.js b/static/galene.js index d958268..81c1c4a 100644 --- a/static/galene.js +++ b/static/galene.js @@ -2531,27 +2531,28 @@ function gotUserMessage(id, dest, username, time, privileged, kind, message) { case 'error': case 'warning': case 'info': - let from = id ? (username || 'Anonymous') : 'The Server'; - if(privileged) - displayError(`${from} said: ${message}`, kind); - else + if(!privileged) { console.error(`Got unprivileged message of kind ${kind}`); + return; + } + let from = id ? (username || 'Anonymous') : 'The Server'; + displayError(`${from} said: ${message}`, kind); break; case 'mute': - if(privileged) { - setLocalMute(true, true); - let by = username ? ' by ' + username : ''; - displayWarning(`You have been muted${by}`); - } else { + if(!privileged) { console.error(`Got unprivileged message of kind ${kind}`); + return; } + setLocalMute(true, true); + let by = username ? ' by ' + username : ''; + displayWarning(`You have been muted${by}`); break; case 'clearchat': - if(privileged) { - clearChat(); - } else { + if(!privileged) { console.error(`Got unprivileged message of kind ${kind}`); + return; } + clearChat(); break; default: console.warn(`Got unknown user message ${kind}`);