import { Controller, Post, Delete, Body, UseGuards, HttpCode, HttpStatus, } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth, } from '@nestjs/swagger'; import { JwtAuthGuard } from '../auth/guards'; import { CurrentUser } from '../auth/decorators'; import { NotificationsService } from './notifications.service'; import { RegisterTokenDto, RemoveTokenDto } from './dto/register-token.dto'; @ApiTags('Notifications') @Controller('notifications') @UseGuards(JwtAuthGuard) @ApiBearerAuth('JWT-auth') export class NotificationsController { constructor( private readonly notificationsService: NotificationsService, ) {} @Post('fcm-token') @HttpCode(HttpStatus.OK) @ApiOperation({ summary: 'Register FCM token for push notifications' }) @ApiResponse({ status: 200, description: 'Token registered' }) async registerToken( @CurrentUser('id') userId: string, @Body() dto: RegisterTokenDto, ) { await this.notificationsService.registerToken( userId, dto.token, dto.device, ); return null; } @Delete('fcm-token') @HttpCode(HttpStatus.OK) @ApiOperation({ summary: 'Remove FCM token' }) @ApiResponse({ status: 200, description: 'Token removed' }) async removeToken( @CurrentUser('id') userId: string, @Body() dto: RemoveTokenDto, ) { await this.notificationsService.removeToken(userId, dto.token); return null; } }