import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common'; import type { AuthUser } from '../auth/auth.types'; import { CurrentUser } from '../auth/decorators/current-user.decorator'; import { Roles } from '../auth/decorators/roles.decorator'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { RolesGuard } from '../auth/guards/roles.guard'; import { ChatService } from './chat.service'; import { SendMessageDto } from './dto/send-message.dto'; @Controller('chat') @UseGuards(JwtAuthGuard, RolesGuard) @Roles('PLATFORM_ADMIN', 'ADMIN', 'MANAGER', 'OPERATOR') export class ChatController { constructor(private readonly chat: ChatService) {} @Get('counts') @Roles('PLATFORM_ADMIN') counts(@CurrentUser() user: AuthUser) { return this.chat.counts(user); } @Get('channel') channel(@CurrentUser() user: AuthUser, @Query('slug') slug?: string) { return this.chat.channel(user, slug); } @Post('messages') send(@CurrentUser() user: AuthUser, @Body() dto: SendMessageDto) { return this.chat.send(user, dto.text, dto.slug); } }