From b291350750d2f860d19e9efc9b6f9ad51943baab Mon Sep 17 00:00:00 2001 From: lim Date: Mon, 4 Mar 2024 15:20:38 +0900 Subject: [PATCH] [backend] Validated to prevent saving empty messages --- backend/src/chat/chat.gateway.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/src/chat/chat.gateway.ts b/backend/src/chat/chat.gateway.ts index b9bd7610..8d78484d 100644 --- a/backend/src/chat/chat.gateway.ts +++ b/backend/src/chat/chat.gateway.ts @@ -65,6 +65,10 @@ export class ChatGateway { if (MutedUsers.some((user) => user.id === data.userId)) { return; } + if (data.content.length < 1) { + this.logger.error('no content in message'); + return; + } // Save message to the database await this.chatService.createMessage(data);