diff --git a/src/notifications/notifications.controller.ts b/src/notifications/notifications.controller.ts index 2fa86a8..3debac0 100644 --- a/src/notifications/notifications.controller.ts +++ b/src/notifications/notifications.controller.ts @@ -91,10 +91,16 @@ export class NotificationsController { @Post('test-push') @HttpCode(HttpStatus.OK) - @ApiOperation({ summary: 'Send a test push notification to the current user' }) + @ApiOperation({ summary: 'Send a test push notification to a specific user (Admin)' }) @ApiResponse({ status: 200, description: 'Test notification sent' }) - async sendTestPush(@CurrentUser('id') userId: string) { - await this.notificationsService.sendTestPushNotification(userId); + async sendTestPush( + @Body() dto: { userId: string; title?: string; body?: string }, + ) { + await this.notificationsService.sendTestPushNotification( + dto.userId, + dto.title, + dto.body, + ); return { message: 'Test push notification sent' }; } diff --git a/src/notifications/notifications.service.ts b/src/notifications/notifications.service.ts index a93b7a8..e849909 100644 --- a/src/notifications/notifications.service.ts +++ b/src/notifications/notifications.service.ts @@ -323,6 +323,23 @@ export class NotificationsService implements OnModuleInit { body: payload.body, }, data: payload.data || {}, + android: { + priority: 'high', + notification: { + channelId: 'high_importance_channel', + priority: 'high', + defaultSound: true, + defaultVibrateTimings: true, + }, + }, + apns: { + payload: { + aps: { + sound: 'default', + badge: 1, + }, + }, + }, webpush: { fcmOptions: { link: payload.data?.link || '/', @@ -375,7 +392,11 @@ export class NotificationsService implements OnModuleInit { // TEST PUSH NOTIFICATION // ========================================== - async sendTestPushNotification(userId: string): Promise { + async sendTestPushNotification( + userId: string, + title?: string, + body?: string, + ): Promise { const user = await this.prisma.user.findUnique({ where: { id: userId }, select: { fcmTokens: true }, @@ -393,8 +414,8 @@ export class NotificationsService implements OnModuleInit { } await this.sendPushNotification(userId, user, { - title: 'Test Notification 🔔', - body: 'This is a test push notification from RE-Quest!', + title: title || 'Test Notification 🔔', + body: body || 'This is a test push notification from RE-Quest!', data: { type: 'test', link: '/' }, });