From cdaa7c678d28a1b806d11a2f23ebfc781f8cc52f Mon Sep 17 00:00:00 2001 From: ari melody Date: Fri, 30 Aug 2024 12:33:40 +0100 Subject: [PATCH] prevent sending or logging of empty chats --- client/js/main.js | 1 + server/ws.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/client/js/main.js b/client/js/main.js index 4325f9d..526a0a7 100644 --- a/client/js/main.js +++ b/client/js/main.js @@ -315,6 +315,7 @@ composeBox.addEventListener("keypress", event => { }); function sendChat(msg) { + if (msg === "") return; setTimeout(() => { if (!ws) return; ws.send(JSON.stringify({ diff --git a/server/ws.js b/server/ws.js index f383cb5..5439792 100644 --- a/server/ws.js +++ b/server/ws.js @@ -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("<", "<") data.msg = data.msg.replaceAll(">", ">") 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",