fix: harden booking and meeting flows

This commit is contained in:
2026-09-17 02:42:27 +02:00
parent cb30ecade9
commit 66710fc65c
42 changed files with 683 additions and 608 deletions
+3 -2
View File
@@ -13,13 +13,14 @@ import type { PayloadRequest } from "payload";
*/
export async function acquireBookingDayLock(req: PayloadRequest, dateKey: string): Promise<void> {
const txID = req.transactionID ? String(await req.transactionID) : undefined;
if (!txID) return; // No active transaction — nothing to lock against.
if (!txID) throw new Error("A booking lock requires an active transaction");
const adapter = req.payload.db as unknown as {
sessions?: Record<string, { db: { execute: (query: unknown) => Promise<unknown> } }>;
drizzle: { execute: (query: unknown) => Promise<unknown> };
};
const tx = adapter.sessions?.[txID]?.db ?? adapter.drizzle;
const tx = adapter.sessions?.[txID]?.db;
if (!tx) throw new Error("Booking transaction not found");
await tx.execute(sql`SELECT pg_advisory_xact_lock(hashtext(${dateKey}))`);
}