dorfteich/apps/api/src/trash/trash.module.ts
Claude Fable 5 960a806ee3
All checks were successful
CI / Lint, typecheck, test (pull_request) Successful in 5m4s
CI / Build container images (pull_request) Successful in 2m47s
CI / Auth e2e pack (pull_request) Successful in 7m44s
CI / Import/export fidelity gate (pull_request) Successful in 55s
CD / Build and push images (push) Successful in 19s
CD / Deploy to Test (push) Successful in 13s
CD / Smoke tests against Test (push) Successful in 1m22s
CD / Promote to Int (push) Successful in 11s
CI / Lint, typecheck, test (push) Successful in 5m9s
CI / Build container images (push) Has been skipped
CI / Auth e2e pack (push) Successful in 7m53s
CI / Import/export fidelity gate (push) Successful in 53s
#195: trashed content leaves the search index itself
Trashing a page (promote and subtree modes) clears the affected search
vectors, restoring rebuilds them; pond trash clears every page vector of
the pond, pond restore reindexes only the live pages (pages trashed
inside stay out); the GDPR pseudonymization's personal-pond trash does
the same. reindexAll now converges to the invariant (clears trashed,
rebuilds live), and a one-off migration backfills vectors of
already-trashed content.

The query-side deleted_at guards stay untouched as the independent
second layer - the test proves both layers separately, including writing
a vector back onto a trashed page (simulating a future path that forgot
the clear) and asserting the query still hides it. New provider methods
removePond/reindexPond behind the SearchProvider seam.

Refs #195

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0168Ph5uBmHm8X28CSVpbpnJ
2026-07-30 14:07:34 +02:00

51 lines
1.5 KiB
TypeScript

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();
},
});
}
}