import { Module, OnModuleInit } from '@nestjs/common'; import { CommonModule } from '../common/common.module'; import { FilesModule } from '../files/files.module'; import { PagesModule } from '../pages/pages.module'; import { PondsModule } from '../ponds/ponds.module'; import { QuotasModule } from '../quotas/quotas.module'; import { SearchModule } from '../search/search.module'; import { WatchesModule } from '../watches/watches.module'; import { SchedulerModule } from '../scheduler/scheduler.module'; import { SchedulerService } from '../scheduler/scheduler.service'; import { TrashController } from './trash.controller'; import { TrashService } from './trash.service'; /** Daily, per operations.md's maintenance-jobs table (ADR 0013). */ const TRASH_PURGE_CADENCE_SECONDS = 24 * 60 * 60; @Module({ imports: [ CommonModule, PondsModule, QuotasModule, FilesModule, PagesModule, SchedulerModule, SearchModule, WatchesModule, ], controllers: [TrashController], providers: [TrashService], }) export class TrashModule implements OnModuleInit { constructor( private readonly scheduler: SchedulerService, private readonly trash: TrashService, ) {} onModuleInit(): void { this.scheduler.register({ name: 'trash-purge', cadenceSeconds: TRASH_PURGE_CADENCE_SECONDS, // Pages first, then whole ponds (issue #193) — same retention clock. run: async () => { await this.trash.purgeDuePages(); await this.trash.purgeDuePonds(); }, }); } }