feat: Implement endpoint and service method for sending test push notifications.

This commit is contained in:
pradeepkumar
2026-03-26 11:22:30 +05:30
parent ddc9c0caaa
commit 924b03f459
2 changed files with 43 additions and 0 deletions

View File

@@ -371,6 +371,36 @@ export class NotificationsService implements OnModuleInit {
}
}
// ==========================================
// TEST PUSH NOTIFICATION
// ==========================================
async sendTestPushNotification(userId: string): Promise<void> {
const user = await this.prisma.user.findUnique({
where: { id: userId },
select: { fcmTokens: true },
});
if (!user) {
this.logger.warn(`Test push: user ${userId} not found`);
return;
}
const tokens = this.parseFcmTokens(user.fcmTokens);
if (tokens.length === 0) {
this.logger.warn(`Test push: no FCM tokens for user ${userId}`);
return;
}
await this.sendPushNotification(userId, user, {
title: 'Test Notification 🔔',
body: 'This is a test push notification from RE-Quest!',
data: { type: 'test', link: '/' },
});
this.logger.log(`Test push notification sent to user ${userId}`);
}
// ==========================================
// EVENT LISTENERS
// ==========================================