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 }; }