sinka/api/src/chat/chat.controller.ts
armando 67589e9ec2 a
2026-09-16 01:33:44 -03:00

32 lines
1.1 KiB
TypeScript

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);
}
}