prevent sending or logging of empty chats

This commit is contained in:
ari melody 2024-08-30 12:33:40 +01:00
parent 5c936df3f6
commit cdaa7c678d
Signed by: ari
GPG key ID: CF99829C92678188
2 changed files with 2 additions and 1 deletions

View file

@ -315,6 +315,7 @@ composeBox.addEventListener("keypress", event => {
});
function sendChat(msg) {
if (msg === "") return;
setTimeout(() => {
if (!ws) return;
ws.send(JSON.stringify({

View file

@ -131,12 +131,12 @@ export function init(http_server) {
case "chat":
if (data.msg === undefined)
throw new Error("Attempted chat with no message");
Log.info('<' + socket.player.name + '> ' + data.msg)
data.msg = data.msg.replaceAll("<", "&lt;")
data.msg = data.msg.replaceAll(">", "&gt;")
data.msg = data.msg.replaceAll("\n", "");
data.msg = data.msg.trim();
if (data.msg == "") return;
Log.info('<' + socket.player.name + '> ' + data.msg)
clients.forEach(client => {
client.send(JSON.stringify({
type: "chat",