feat: Implement connection request response notifications and emit them upon status update.
This commit is contained in:
@@ -444,4 +444,33 @@ export class NotificationsService implements OnModuleInit {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@OnEvent('notification.connection_response')
|
||||
async handleConnectionResponseNotification(event: {
|
||||
recipientUserId: string;
|
||||
agentName: string;
|
||||
status: string;
|
||||
connectionRequestId: string;
|
||||
}) {
|
||||
const isAccepted = event.status === 'ACCEPTED';
|
||||
const prefix = await this.getRoutePrefix(event.recipientUserId);
|
||||
const actionUrl = isAccepted ? `${prefix}/message` : `${prefix}/profiles`;
|
||||
|
||||
await this.createAndSendNotification(
|
||||
event.recipientUserId,
|
||||
'connection',
|
||||
isAccepted ? 'Connection Accepted' : 'Connection Declined',
|
||||
isAccepted
|
||||
? `${event.agentName} accepted your connection request. You can now send messages.`
|
||||
: `${event.agentName} declined your connection request.`,
|
||||
'new_lead_alerts',
|
||||
actionUrl,
|
||||
{
|
||||
type: 'connection_response',
|
||||
status: event.status,
|
||||
connectionRequestId: event.connectionRequestId,
|
||||
link: actionUrl,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user