From b0eae860bfb3bbaa774a452e0767c655667f61a3 Mon Sep 17 00:00:00 2001 From: xangelo Date: Wed, 25 May 2022 16:03:05 -0400 Subject: [PATCH] dont allow empty chat messages --- src/api.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/api.ts b/src/api.ts index 1c1aab0..b086ff3 100644 --- a/src/api.ts +++ b/src/api.ts @@ -361,14 +361,16 @@ server.post<{body: {message: string}}, void>('/chat', async req => { const acct = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token); const now = Date.now(); - console.log(acct.username, req.body.message, now); - - const msg = renderPublicChatMessage(acct.username, req.body.message); - server.ws.emit('/chat-message', msg); - msgBuffer.unshift(msg); - while(msgBuffer.length > 30) { - msgBuffer.pop(); + if(!_.isEmpty(req.body.message)) { + const msg = renderPublicChatMessage(acct.username, req.body.message); + server.ws.emit('/chat-message', msg); + msgBuffer.unshift(msg); + while(msgBuffer.length > 30) { + msgBuffer.pop(); + } } + + return; }); server.ws.on('connection', async socket => { -- 2.25.1