import { Controller, Get, Param, Post, Query } from '@nestjs/common';
import { Paginate, PaginateQuery } from 'nestjs-paginate';
import { ConversationsService } from './conversations.service';
import { Conversation } from '@/entities/conversation.entity';

@Controller('conversations')
export class ConversationsController {
  constructor(private readonly service: ConversationsService) {}

  @Get('')
  getConversations(
    @Paginate() query: PaginateQuery,
    @Query('current') current: boolean = true,
  ) {
    return this.service.index({ ...query, current });
  }

  @Post('prefix')
  getConversationsByPrefix() {
    return this.service.getConversationsByPrefix();
  }

  @Get(':id')
  getConversation(@Param('id') id: Conversation['id']) {
    return this.service.getConversation(id);
  }
}
