From d84e55cb6183502983826e4555a66c9ab5c06817 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Mon, 13 Apr 2026 22:48:05 +0530 Subject: [PATCH] feat: mark related message notifications as read when updating conversation unread count --- src/messages/messages.service.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/messages/messages.service.ts b/src/messages/messages.service.ts index 97a6dba..84508bb 100644 --- a/src/messages/messages.service.ts +++ b/src/messages/messages.service.ts @@ -562,6 +562,21 @@ export class MessagesService { data: isUser ? { userUnreadCount: 0 } : { agentUnreadCount: 0 }, }); + // Also mark related message notifications as read for this user + // Notifications store conversationId in the JSON `data` field + await this.prisma.notification.updateMany({ + where: { + userId, + type: 'message', + read: false, + data: { + path: ['conversationId'], + equals: conversationId, + }, + }, + data: { read: true }, + }); + return { success: true }; }