refactor(plugins): async DB-touching methods; transactions through UnitOfWork

This commit is contained in:
jubnl
2026-09-22 00:00:53 +02:00
parent e413308227
commit e28dc6de28
68 changed files with 743 additions and 706 deletions
+4 -4
View File
@@ -6,19 +6,19 @@
// (the plugin side persists the erasure so nothing is lost if the sink is absent
// or the runtime is mid-boot).
let sink: ((userId: number) => void) | null = null;
let sink: ((userId: number) => void | Promise<void>) | null = null;
export function setUserDeletedSink(fn: ((userId: number) => void) | null): void {
export function setUserDeletedSink(fn: ((userId: number) => void | Promise<void>) | null): void {
sink = fn;
}
/** Announce that a TREK account was fully deleted. Called by the core deletion
* paths after deleteUserCompletely so plugins can erase their own per-user data.
* Swallows everything: a plugin bookkeeping error must never fail the deletion. */
export function emitUserDeleted(userId: number): void {
export async function emitUserDeleted(userId: number): Promise<void> {
if (!sink) return;
try {
sink(userId);
await sink(userId);
} catch {
/* the erasure is enqueued transactionally on the plugin side; a sink hiccup
is non-fatal and the next runtime boot reconciles from the queue */