Files
HealthLog/src/lib/jobs/document-purge-queue.ts
T
Marc-André Bombeck 4752115d7d feat(documents): add Recently deleted for deleted documents
Deleting a document only stamps a tombstone and the purge removes it
after 30 days, but the only way back was the undo toast, gone a few
seconds after the delete. Recently deleted lists the deleted documents
of the record with type, filing date, where an import came from, when
each was deleted and how long it has left, and offers Restore, Restore
all and Delete now.

GET /api/documents/inbound/deleted lists them (owner-only, capped at 200
with the list-cap meta). POST /api/documents/inbound/{id}/purge removes
one deleted document for good through the same function the nightly
purge runs, so its import keys and aliases still move into the ledger
and an importer re-sending it is still answered "deleted"; a live
document answers 409 documents.inbound.notDeleted. The usage read gains
deletedCount, 0 under a grant. The restore route and bulk restore
share one restore, which now also clears ledger entries for the
document's own keys.

The vault header shows a quiet "Recently deleted (n)" link only while
something is in it, and the delete toasts and confirmations say that
deleted documents stay there for 30 days. The purge's queue facts and
grace window move to document-purge-queue.ts so the worker registry
still loads none of the work.

Refs #1275
2026-10-24 20:51:35 +02:00

18 lines
835 B
TypeScript

/**
* The queue facts of `document-purge.ts`: its name, its schedule and the grace
* window it enforces. They live apart from the handler so the worker registry
* can read them without loading the purge (and the document modules it shares
* with "Delete now"). Constants only: client code reads the grace window
* through `@/lib/documents/inbound-constants`.
*/
export const DOCUMENT_PURGE_QUEUE = "document-tombstone-purge";
/** Daily at 04:10 Europe/Berlin — after the med-notes backfill tick (04:05). */
export const DOCUMENT_PURGE_CRON = "10 4 * * *";
/**
* Days a deleted document stays in Recently deleted (restorable) before the
* daily purge removes it for good. The purge, the list of deleted documents
* and the copy that names the window all read this one value.
*/
export const DOCUMENT_PURGE_GRACE_DAYS = 30;