From: xangelo Date: Wed, 25 May 2022 20:03:05 +0000 (-0400) Subject: dont allow empty chat messages X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=b0eae860bfb3bbaa774a452e0767c655667f61a3;p=browser-rts.git dont allow empty chat messages --- 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 => {