import { Body, Controller, Get, Inject, Post, Put, Query, UseGuards, } from "@nestjs/common"; import { AuthGuard } from "../auth/auth.guard.js"; import { CurrentUser } from "../auth/current-user.decorator.js"; import type { AccessClaims } from "../auth/token.service.js"; import { StateChangingOriginGuard } from "../conversation/state-changing-origin.guard.js"; import { NotificationQueryDto, PushPreferenceDto, ReadNotificationsDto, } from "../safety/dto.js"; import { NotificationService } from "./notification.service.js"; @Controller() @UseGuards(AuthGuard) export class NotificationController { constructor( @Inject(NotificationService) private readonly notifications: NotificationService, ) {} @Get("notifications") list( @CurrentUser() u: AccessClaims, @Query() q: NotificationQueryDto, ) { return this.notifications.list(u.sub, q.cursor, q.limit); } @UseGuards(StateChangingOriginGuard) @Post("notifications/read") read( @CurrentUser() u: AccessClaims, @Body() d: ReadNotificationsDto, ) { return this.notifications.read(u.sub, d.ids); } @Get("settings/push") pref(@CurrentUser() u: AccessClaims) { return this.notifications.preference(u.sub); } @UseGuards(StateChangingOriginGuard) @Put("settings/push") update( @CurrentUser() u: AccessClaims, @Body() d: PushPreferenceDto, ) { return this.notifications.updatePreference(u.sub, d.inAppEnabled); } } Reflect.defineMetadata( "design:paramtypes", [Object, NotificationQueryDto], NotificationController.prototype, "list", ); Reflect.defineMetadata( "design:paramtypes", [Object, ReadNotificationsDto], NotificationController.prototype, "read", ); Reflect.defineMetadata( "design:paramtypes", [Object], NotificationController.prototype, "pref", ); Reflect.defineMetadata( "design:paramtypes", [Object, PushPreferenceDto], NotificationController.prototype, "update", );