feat: Implement connection request response notifications and emit them upon status update.
This commit is contained in:
@@ -241,7 +241,7 @@ export class ConnectionRequestsService {
|
||||
throw new BadRequestException('This request has already been responded to');
|
||||
}
|
||||
|
||||
return this.prisma.connectionRequest.update({
|
||||
const updated = await this.prisma.connectionRequest.update({
|
||||
where: { id: requestId },
|
||||
data: {
|
||||
status: dto.status as ConnectionStatus,
|
||||
@@ -257,6 +257,25 @@ export class ConnectionRequestsService {
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Get agent name for notification
|
||||
const agentProfile = await this.prisma.agentProfile.findUnique({
|
||||
where: { id: agentProfileId },
|
||||
select: { firstName: true, lastName: true },
|
||||
});
|
||||
const agentName = agentProfile
|
||||
? `${agentProfile.firstName || ''} ${agentProfile.lastName || ''}`.trim()
|
||||
: 'An agent';
|
||||
|
||||
// Notify the user about the accept/reject
|
||||
this.eventEmitter.emit('notification.connection_response', {
|
||||
recipientUserId: request.userId,
|
||||
agentName,
|
||||
status: dto.status,
|
||||
connectionRequestId: requestId,
|
||||
});
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user