- Add ListingFlag model with FlagReason enum (SCAM, DUPLICATE, WRONG_INFO, ALREADY_SOLD, INAPPROPRIATE) - Add POST /listings/:id/report endpoint with rate limiting and duplicate prevention - Auto-flag listings with ≥3 reports to PENDING_REVIEW for moderator review - Add GET /admin/flagged-listings endpoint for admin moderation queue - Add "Báo cáo" button + modal on listing detail page (Vietnamese UI) - Add Prisma migration for listing_flags table with unique constraint per user/listing Co-Authored-By: Paperclip <noreply@paperclip.ing>
53 lines
2.2 KiB
TypeScript
53 lines
2.2 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { CqrsModule } from '@nestjs/cqrs';
|
|
import { CancelSubscriptionHandler } from './application/commands/cancel-subscription/cancel-subscription.handler';
|
|
import { CreateSubscriptionHandler } from './application/commands/create-subscription/create-subscription.handler';
|
|
import { MeterUsageHandler } from './application/commands/meter-usage/meter-usage.handler';
|
|
import { UpgradeSubscriptionHandler } from './application/commands/upgrade-subscription/upgrade-subscription.handler';
|
|
import { CheckQuotaHandler } from './application/queries/check-quota/check-quota.handler';
|
|
import { GetBillingHistoryHandler } from './application/queries/get-billing-history/get-billing-history.handler';
|
|
import { GetPlanHandler } from './application/queries/get-plan/get-plan.handler';
|
|
import { SUBSCRIPTION_REPOSITORY } from './domain/repositories/subscription.repository';
|
|
import { BankTransferSubscriptionActivationHandler } from './infrastructure/event-handlers/bank-transfer-subscription-activation.handler';
|
|
import { ListingCreatedUsageHandler } from './infrastructure/event-handlers/listing-created-usage.handler';
|
|
import { SavedSearchCreatedUsageHandler } from './infrastructure/event-handlers/saved-search-created-usage.handler';
|
|
import { PrismaSubscriptionRepository } from './infrastructure/repositories/prisma-subscription.repository';
|
|
import { SubscriptionsController } from './presentation/controllers/subscriptions.controller';
|
|
import { QuotaGuard } from './presentation/guards/quota.guard';
|
|
|
|
const CommandHandlers = [
|
|
CreateSubscriptionHandler,
|
|
UpgradeSubscriptionHandler,
|
|
CancelSubscriptionHandler,
|
|
MeterUsageHandler,
|
|
];
|
|
|
|
const QueryHandlers = [
|
|
GetPlanHandler,
|
|
CheckQuotaHandler,
|
|
GetBillingHistoryHandler,
|
|
];
|
|
|
|
@Module({
|
|
imports: [CqrsModule],
|
|
controllers: [SubscriptionsController],
|
|
providers: [
|
|
// Repositories
|
|
{ provide: SUBSCRIPTION_REPOSITORY, useClass: PrismaSubscriptionRepository },
|
|
|
|
// Guards
|
|
QuotaGuard,
|
|
|
|
// Event Listeners
|
|
ListingCreatedUsageHandler,
|
|
SavedSearchCreatedUsageHandler,
|
|
BankTransferSubscriptionActivationHandler,
|
|
|
|
// CQRS
|
|
...CommandHandlers,
|
|
...QueryHandlers,
|
|
],
|
|
exports: [SUBSCRIPTION_REPOSITORY, QuotaGuard],
|
|
})
|
|
export class SubscriptionsModule {}
|