mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 14:36:31 +00:00
refactor(plugins): async DB-touching methods; transactions through UnitOfWork
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user