feat: Implement real-time message delivery for conversations via WebSocket integration and update admin seed email.

This commit is contained in:
pradeepkumar
2026-03-18 16:49:13 +05:30
parent 2cb4a649bd
commit c3a3df704e
3 changed files with 31 additions and 10 deletions

View File

@@ -175,13 +175,8 @@ export class MessagesGateway implements OnGatewayConnection, OnGatewayDisconnect
data.message,
);
// Broadcast to other clients in the conversation room (exclude sender)
client
.to(`conversation:${data.conversationId}`)
.emit('new_message', message);
// Also send directly to the other participant's socket(s)
// so they receive the message even if they haven't joined this room
// Send directly to the other participant's socket(s)
// This is the primary delivery mechanism — works even if they haven't joined the room
try {
const participants = await this.messagesService.getConversationParticipants(data.conversationId);
if (participants) {
@@ -194,6 +189,12 @@ export class MessagesGateway implements OnGatewayConnection, OnGatewayDisconnect
this.logger.warn(`Failed to get participants for direct delivery in ${data.conversationId}: ${participantError.message}`);
}
// Also broadcast to the conversation room as a fallback
// (client.to excludes sender; recipients dedup by message ID)
client
.to(`conversation:${data.conversationId}`)
.emit('new_message', message);
return { success: true, message };
} catch (error) {
return { error: error.message };