From eb6a78ead902ffe1cdae7cfc0dc62b417e5164ae Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Thu, 9 Apr 2026 16:02:24 +0530 Subject: [PATCH] feat: notify other participant via gateway when a conversation is deleted --- src/messages/messages.controller.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/messages/messages.controller.ts b/src/messages/messages.controller.ts index 9308ee6..89e4d16 100644 --- a/src/messages/messages.controller.ts +++ b/src/messages/messages.controller.ts @@ -298,7 +298,22 @@ export class MessagesController { @Param('id') conversationId: string, @CurrentUser('id') userId: string, ) { - return this.messagesService.deleteConversation(conversationId, userId); + // Get the other party before deletion so we can notify them + const participants = await this.messagesService.getConversationParticipants(conversationId); + const result = await this.messagesService.deleteConversation(conversationId, userId); + + // Notify the other party so their client removes the stale conversation + if (participants) { + const otherUserId = userId === participants.userId + ? participants.agentUserId + : participants.userId; + this.messagesGateway.sendToUser(otherUserId, 'conversation_deleted', { + conversationId, + deletedBy: userId, + }); + } + + return result; } // ==========================================