| 1 | import { |
| 2 | Body, |
| 3 | Controller, |
| 4 | Get, |
| 5 | HttpCode, |
| 6 | HttpStatus, |
| 7 | Param, |
| 8 | Patch, |
| 9 | Post, |
| 10 | Query, |
| 11 | Session, |
| 12 | } from '@nestjs/common'; |
| 13 | import { |
| 14 | ApiBadRequestResponse, |
| 15 | ApiNoContentResponse, |
| 16 | ApiNotFoundResponse, |
| 17 | ApiOkResponse, |
| 18 | ApiOperation, |
| 19 | ApiTags, |
| 20 | ApiUnauthorizedResponse, |
| 21 | } from '@nestjs/swagger'; |
| 22 | import type { UserSession |
| 23 | |
| 24 | import { ErrorResponseDTO } |
| 25 | import { |
| 26 | GetNotificationsQueryDTO, |
| 27 | GetNotificationsResponseDTO, |
| 28 | UnreadCountResponseDTO, |
| 29 | UpdateNotificationRequestDTO, |
| 30 | } from './dto/notification.dto.js'; |
| 31 | import { NotificationsService } |
| 32 | |
| 33 | @Controller('notifications') |
| 34 | @ApiTags('Notifications') |
| 35 | @ApiUnauthorizedResponse({ type: |
| 36 | export class NotificationsController |
| 37 | constructor(private readonly |
| 38 | |
| 39 | @Get() |
| 40 | @ApiOperation({ |
| 41 | summary: 'List notifications', |
| 42 | description: |
| 43 | "The signed-in user's inbox, one entry per thread, most recently active first. Pages are cursor-based: pass a response `nextCursor` back as `cursor`.", |
| 44 | }) |
| 45 | @ApiOkResponse({ type |
| 46 | @ApiBadRequestResponse({ type |
| 47 | list( |
| 48 | @Query() query |
| 49 | @Session() session |
| 50 | ): Promise<GetNotificationsResponseDTO |
| 51 | return this.notifications |
| 52 | } |
| 53 | |
| 54 | @Get('unread-count' |
| 55 | @ApiOperation({ summary |
| 56 | @ApiOkResponse({ type |
| 57 | unreadCount( |
| 58 | @Session() session |
| 59 | ): Promise<UnreadCountResponseDTO |
| 60 | return this.notifications |
| 61 | } |
| 62 | |
| 63 | @Post('read' |
| 64 | @HttpCode(HttpStatus. |
| 65 | @ApiOperation({ summary |
| 66 | @ApiNoContentResponse() |
| 67 | markAllRead(@Session() |
| 68 | return this.notifications |
| 69 | } |
| 70 | |
| 71 | @Patch(':id' |
| 72 | @HttpCode(HttpStatus. |
| 73 | @ApiOperation({ summary |
| 74 | @ApiNoContentResponse() |
| 75 | @ApiNotFoundResponse({ type |
| 76 | update( |
| 77 | @Param('id' |
| 78 | @Body() body |
| 79 | @Session() session |
| 80 | ): Promise<void |
| 81 | return this.notifications |
| 82 | } |
| 83 | } |