diff --git a/src/messages/messages.controller.ts b/src/messages/messages.controller.ts index a387b96..90cf02a 100644 --- a/src/messages/messages.controller.ts +++ b/src/messages/messages.controller.ts @@ -215,7 +215,23 @@ export class MessagesController { @Param('id') conversationId: string, @CurrentUser('id') userId: string, ) { - return this.messagesService.markMessagesAsRead(conversationId, userId); + const result = await this.messagesService.markMessagesAsRead(conversationId, userId); + + // Emit socket event so sender gets real-time blue tick + const participants = await this.messagesService.getConversationParticipants(conversationId); + if (participants) { + const otherUserId = userId === participants.userId + ? participants.agentUserId + : participants.userId; + const readEvent = { + conversationId, + readBy: userId, + readAt: new Date(), + }; + this.messagesGateway.sendToUser(otherUserId, 'messages_read', readEvent); + } + + return result; } // ==========================================