What this is
Swappr supports both legs of the GDPR “data subject rights” surface that an individual user can self-serve:
This page covers the lifecycle of both — what’s included, what’s deliberately carved out, why the user row is tombstoned rather than deleted, the cron timing, and the failure semantics that keep the workers idempotent. Source of truth: SWAPPR_BACKEND_PLAN §14.3 + QUESTIONS.md §9.1.
Right of access — data export
The flow
The 24-hour rate limit
A user is limited to one successful export per 24h. The rate-limit check is on the latest non-FAILED row:
The
resetAt returned to the controller is latest.requestedAt + 24h, giving the client a precise wait time.
What is in the export
The export is versioned (
GDPR_EXPORT_VERSION = 1) so a future schema change can be detected by automated processing.
Signed-URL semantics
- The email contains a 24-hour signed GET URL minted at READY time.
GET /me/export/:jobIdalso returns a freshly minted 24h URL on every poll, as long as the underlying row hasn’t passedexpiresAt.- The underlying S3 object lives for 30 days from completion; after that it’s eligible for cleanup (a future broom job, not implemented in Phase 7).
Right to erasure — account delete
The two-step model
Erasure is two-stage, and the first stage is reversible for the whole 30-day window:- Day 0 — soft-delete (
DELETE /me). Re-auth via current password → setusers.deletedAt, revoke all refresh tokens, cascade soft-delete tocurrent_homes. The row physically remains. - Days 0–30 — reversible (
POST /auth/reactivate). The user can undo the deletion by re-authenticating; this clearsdeletedAt/deletedReason, issues a fresh session, and writes auser.reactivatedaudit row. A plain login during this window does not reactivate — it returns403 ACCOUNT_PENDING_DELETION(carryingmeta.deletionScheduledAt), which is the client’s cue to show a reactivation screen. - Day 30 — hard-delete + tombstone (the daily 04:00 UTC
gdpr-erasureworker, or a SUPER admin’s manual trigger). Child rows are hard-deleted; the user row is tombstoned (PII nulled,userErasedAtset). Past this point reactivation is impossible.
Why tombstone, not hard-delete?
The user row’s_id is referenced by:
audit_logs.actorId— admin actions performed against this user, or actions this user performed. Per §14.3 we keep the row but anonymize theactorIdtonulland the JSONpayloadfor any rows whereactorId === userId.subscriptions.userId— financial records (7-year retention required under UK law).conversations.participantIdsthat other users were part of.
_id alive while nulling all PII fields (email, firstName, lastName, dateOfBirth, passwordHash, phone) and setting userErasedAt — preserves FK integrity for the surviving counterparties’ data while still satisfying erasure (no PII left on the row).
Carve-outs
Per QUESTIONS.md §9.1 + §14.3, three classes of data survive the 30-day erasure:
Everything else —
current_homes, user_preferences, tenancy_verifications, uploads (rows + S3 objects), matches, conversations + messages where the user is a participant, reports (filed by OR against the user), blocks (both directions), refresh_tokens — is hard-deleted.
Cron timing
The 1-hour offset is deliberate — retention runs first so a tenancy document that’s both “30d post-decision” AND “owned by a soft-deleted user” is removed by retention first (its dedicated path), and the erasure worker doesn’t need to re-handle it.
The manual trigger
POST /admin/erasure/run — SUPER only — lets ops enqueue a one-off run mid-day. Same handler as the scheduled run; returns 202 Accepted with no result counts (logged by the worker). Mirrors the retention manual trigger shape exactly.
Failure semantics
The erasure worker uses per-usertry/catch and never fails the whole batch on one bad user:
A run that hits 50 failures and 450 successes processes the 50 again tomorrow. The per-run cap is 500 users to match retention.
Failure isolation and observability
Both workers log a run summary ({ scanned, erased, failed, cutoff } for erasure; the equivalent for export). The currently observable trail:
- Worker logs — every run summary, every per-row failure with structured fields.
- Audit log — manual triggers (retention + erasure) write a normal admin-actor audit row. The autonomous daily runs do not write to the audit log (deferred decision — see tenancy-retention for the parallel discussion).
See also
- Request GDPR data export — the user-facing entry point.
- Get export status — poll the export job.
- Delete account — the user-facing erasure entry point.
- Trigger erasure run — SUPER-only manual kick.
- Tenancy retention — the sibling 30-day deletion worker for tenancy documents.
- Worker bootstrap and queues — the BullMQ wiring + scheduling.
apps/worker/src/jobs/gdpr-export.ts— export job handler.apps/worker/src/jobs/gdpr-erasure.ts— erasure job handler.apps/api/src/modules/me/delete-account.service.ts— the soft-delete entry point.