feat: Introduce agent profile verification history tracking and status notifications for agents.
This commit is contained in:
@@ -473,4 +473,55 @@ export class NotificationsService implements OnModuleInit {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@OnEvent('notification.verification')
|
||||
async handleVerificationNotification(event: {
|
||||
recipientUserId: string;
|
||||
status: string;
|
||||
note?: string;
|
||||
agentName: string;
|
||||
}) {
|
||||
const isApproved = event.status === 'APPROVED';
|
||||
const actionUrl = '/agent/dashboard';
|
||||
|
||||
const title = isApproved
|
||||
? 'Profile Verified!'
|
||||
: 'Profile Verification Update';
|
||||
|
||||
const description = isApproved
|
||||
? 'Congratulations! Your profile has been verified. You now have the verified badge on your profile.'
|
||||
: `Your profile verification was not approved.${event.note ? ` Reason: ${event.note}` : ''} Please review and resubmit.`;
|
||||
|
||||
// Create in-app notification + push (always for verification)
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: { id: event.recipientUserId },
|
||||
select: { email: true, fcmTokens: true },
|
||||
});
|
||||
|
||||
if (!user) return;
|
||||
|
||||
// Always create in-app notification
|
||||
await this.prisma.notification.create({
|
||||
data: {
|
||||
userId: event.recipientUserId,
|
||||
type: 'system',
|
||||
title,
|
||||
description,
|
||||
actionUrl,
|
||||
data: { type: 'verification', status: event.status, link: actionUrl },
|
||||
},
|
||||
});
|
||||
|
||||
// Always send push notification
|
||||
await this.sendPushNotification(event.recipientUserId, user, {
|
||||
title,
|
||||
body: description,
|
||||
data: { type: 'verification', status: event.status, link: actionUrl },
|
||||
});
|
||||
|
||||
// Always send email — forced, ignores preferences
|
||||
if (user.email) {
|
||||
await this.sendEmailNotification(user.email, title, description, actionUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user