feat: emit real-time messages_read socket event when marking conversation as read

This commit is contained in:
pradeepkumar
2026-03-31 19:28:48 +05:30
parent bd79e09b7f
commit 475bc9e251

View File

@@ -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;
}
// ==========================================