diff --git a/src/connection-requests/connection-requests.service.ts b/src/connection-requests/connection-requests.service.ts index 25cde5c..578e48a 100644 --- a/src/connection-requests/connection-requests.service.ts +++ b/src/connection-requests/connection-requests.service.ts @@ -315,6 +315,7 @@ export class ConnectionRequestsService { this.eventEmitter.emit('notification.connection_response', { recipientUserId: request.userId, agentName, + agentProfileId, status: dto.status, connectionRequestId: requestId, }); diff --git a/src/notifications/notifications.service.ts b/src/notifications/notifications.service.ts index bc7774e..9867378 100644 --- a/src/notifications/notifications.service.ts +++ b/src/notifications/notifications.service.ts @@ -543,12 +543,20 @@ export class NotificationsService implements OnModuleInit { async handleConnectionResponseNotification(event: { recipientUserId: string; agentName: string; + agentProfileId?: string; status: string; connectionRequestId: string; }) { const isAccepted = event.status === 'ACCEPTED'; const prefix = await this.getRoutePrefix(event.recipientUserId); - const actionUrl = isAccepted ? `${prefix}/message` : `${prefix}/profiles`; + // When accepted, take the user directly to the agent's profile page. + // Fall back to messages view if we don't know the agentProfileId, and to + // the profiles list when declined. + const actionUrl = isAccepted + ? event.agentProfileId + ? `${prefix}/profile/${event.agentProfileId}` + : `${prefix}/message` + : `${prefix}/profiles`; // Send real-time socket event so user sees response instantly this.messagesGateway.sendToUser(event.recipientUserId, 'connection_response', {