refactor: update deleteConversation to perform soft-delete without notifying other participants

This commit is contained in:
pradeepkumar
2026-04-10 17:44:38 +05:30
parent 78133497b3
commit 09003bd409

View File

@@ -298,22 +298,9 @@ export class MessagesController {
@Param('id') conversationId: string, @Param('id') conversationId: string,
@CurrentUser('id') userId: string, @CurrentUser('id') userId: string,
) { ) {
// Get the other party before deletion so we can notify them // Soft-delete: only hides the conversation for the requesting user.
const participants = await this.messagesService.getConversationParticipants(conversationId); // The other party is NOT notified — their view is unaffected.
const result = await this.messagesService.deleteConversation(conversationId, userId); return 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;
} }
// ========================================== // ==========================================