import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { PrivateChatService } from './private-chat.service';
import { SendPrivateMessageDto } from './dto/send-private-message.dto';

@ApiTags('Private Chat')
@Controller('private-chat')
export class PrivateChatController {
  constructor(private readonly privateChatService: PrivateChatService) {}

  @Post('send')
  send(@Body() dto: SendPrivateMessageDto) {
    return this.privateChatService.send(dto);
  }

  @Get('conversation/:userA/:userB')
  conversation(
    @Param('userA') userA: string,
    @Param('userB') userB: string,
    @Query('limit') limit?: string,
  ) {
    return this.privateChatService.conversation(
      userA,
      userB,
      limit ? Number(limit) : 50,
    );
  }

  @Patch(':id/delivered')
  markDelivered(@Param('id') id: string) {
    return this.privateChatService.markDelivered(id);
  }

  @Patch(':id/read')
  markRead(@Param('id') id: string) {
    return this.privateChatService.markRead(id);
  }

  @Patch(':id')
  edit(@Param('id') id: string, @Body('content') content: string) {
    return this.privateChatService.edit(id, content);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.privateChatService.remove(id);
  }
}
