import { Inject } from '@nestjs/common';
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
import { ADMIN_QUERY_REPOSITORY, type IAdminQueryRepository, type ModerationQueueResult } from '../../../domain/repositories/admin-query.repository';
import { GetModerationQueueQuery } from './get-moderation-queue.query';

@QueryHandler(GetModerationQueueQuery)
export class GetModerationQueueHandler implements IQueryHandler<GetModerationQueueQuery> {
  constructor(
    @Inject(ADMIN_QUERY_REPOSITORY) private readonly adminQueryRepo: IAdminQueryRepository,
  ) {}

  async execute(query: GetModerationQueueQuery): Promise<ModerationQueueResult> {
    return this.adminQueryRepo.getModerationQueue(query.page, query.limit);
  }
}
