fix: wrap admin room join logic in try-catch to prevent connection failures and remove redundant comment
This commit is contained in:
@@ -112,11 +112,16 @@ export class MessagesGateway implements OnGatewayConnection, OnGatewayDisconnect
|
||||
|
||||
this.logger.log(`Client connected successfully: ${client.id} (User: ${userId}, Role: ${payload.role})`);
|
||||
|
||||
// Everything below is best-effort — don't let DB errors kill the socket connection
|
||||
try {
|
||||
// Auto-join admin users to admin_room for support chat notifications
|
||||
if (payload.role === 'ADMIN' || payload.role === 'SUPER_ADMIN') {
|
||||
client.join('admin_room');
|
||||
this.logger.log(`Admin ${userId} joined admin_room`);
|
||||
}
|
||||
} catch (err) {
|
||||
this.logger.warn(`Failed to join admin room for ${userId}: ${err.message}`);
|
||||
}
|
||||
|
||||
// Update user online status in background (don't await)
|
||||
this.messagesService.updateOnlineStatus(userId, true)
|
||||
@@ -132,7 +137,6 @@ export class MessagesGateway implements OnGatewayConnection, OnGatewayDisconnect
|
||||
this.messagesService.markPendingMessagesAsDelivered(userId)
|
||||
.then((results) => {
|
||||
for (const result of results) {
|
||||
// Notify each sender that their messages were delivered
|
||||
const deliveredEvent = {
|
||||
messageIds: result.messageIds,
|
||||
conversationId: result.conversationId,
|
||||
|
||||
Reference in New Issue
Block a user