dont allow empty chat messages
authorxangelo <git@xangelo.ca>
Wed, 25 May 2022 20:03:05 +0000 (16:03 -0400)
committerxangelo <git@xangelo.ca>
Wed, 25 May 2022 20:03:05 +0000 (16:03 -0400)
src/api.ts

index 1c1aab03c98b9d93ad270277228ee765f535df37..b086ff3534e1d36a77c4b3157ed30e11510c4ff6 100644 (file)
@@ -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 => {