feat: notify other participant via gateway when a conversation is deleted

This commit is contained in:
pradeepkumar
2026-04-09 16:02:24 +05:30
parent 1843db79f3
commit eb6a78ead9

View File

@@ -298,7 +298,22 @@ export class MessagesController {
@Param('id') conversationId: string, @Param('id') conversationId: string,
@CurrentUser('id') userId: 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;
} }
// ========================================== // ==========================================