1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Simplify checking for privileged user messages.

This commit is contained in:
Juliusz Chroboczek 2022-12-17 00:15:07 +01:00
parent fae045fb61
commit 056f98604a

View file

@ -2531,27 +2531,28 @@ function gotUserMessage(id, dest, username, time, privileged, kind, message) {
case 'error': case 'error':
case 'warning': case 'warning':
case 'info': case 'info':
let from = id ? (username || 'Anonymous') : 'The Server'; if(!privileged) {
if(privileged)
displayError(`${from} said: ${message}`, kind);
else
console.error(`Got unprivileged message of kind ${kind}`); console.error(`Got unprivileged message of kind ${kind}`);
return;
}
let from = id ? (username || 'Anonymous') : 'The Server';
displayError(`${from} said: ${message}`, kind);
break; break;
case 'mute': case 'mute':
if(privileged) { if(!privileged) {
console.error(`Got unprivileged message of kind ${kind}`);
return;
}
setLocalMute(true, true); setLocalMute(true, true);
let by = username ? ' by ' + username : ''; let by = username ? ' by ' + username : '';
displayWarning(`You have been muted${by}`); displayWarning(`You have been muted${by}`);
} else {
console.error(`Got unprivileged message of kind ${kind}`);
}
break; break;
case 'clearchat': case 'clearchat':
if(privileged) { if(!privileged) {
clearChat();
} else {
console.error(`Got unprivileged message of kind ${kind}`); console.error(`Got unprivileged message of kind ${kind}`);
return;
} }
clearChat();
break; break;
default: default:
console.warn(`Got unknown user message ${kind}`); console.warn(`Got unknown user message ${kind}`);