fix: email

This commit is contained in:
2026-03-11 16:34:51 +01:00
parent 17aa8956a7
commit 7f431c0091
7 changed files with 301 additions and 676 deletions

View File

@@ -0,0 +1,9 @@
// ---------------------------------------------------------------------------
// Single source-of-truth for event details used across the API
// ---------------------------------------------------------------------------
export const EVENT = "Open Mic Night — vrijdag 18 april 2026";
export const OPENS = "maandag 16 maart 2026 om 19:00";
// Registration opens — used for reminder scheduling windows
export const REGISTRATION_OPENS_AT = new Date("2026-03-16T19:00:00+01:00");

File diff suppressed because it is too large Load Diff

View File

@@ -348,7 +348,7 @@ export const drinkkaartRouter = {
.then((r) => r[0]);
if (cardUser) {
sendDeductionEmail({
await sendDeductionEmail({
to: cardUser.email,
firstName: cardUser.name.split(" ")[0] ?? cardUser.name,
amountCents: input.amountCents,

View File

@@ -18,6 +18,7 @@ import {
sum,
} from "drizzle-orm";
import { z } from "zod";
import { REGISTRATION_OPENS_AT } from "../constants";
import {
emailLog,
sendCancellationEmail,
@@ -32,8 +33,7 @@ import { adminProcedure, protectedProcedure, publicProcedure } from "../index";
import { generateQrSecret } from "../lib/drinkkaart-utils";
import { drinkkaartRouter } from "./drinkkaart";
// Registration opens at this date — reminders fire 24 hours and 1 hour before
const REGISTRATION_OPENS_AT = new Date("2026-03-16T19:00:00+01:00");
// Reminder windows derived from the canonical registration open date
const REMINDER_1H_WINDOW_START = new Date(
REGISTRATION_OPENS_AT.getTime() - 60 * 60 * 1000,
);
@@ -879,13 +879,15 @@ export const appRouter = {
email: input.email,
});
// Fire-and-forget — don't let a mail failure block the response
sendSubscriptionConfirmationEmail({ to: input.email }).catch((err) =>
emailLog("error", "email.catch", {
type: "subscription_confirmation",
to: input.email,
error: String(err),
}),
// Awaited — CF Workers abandon unawaited promises when the response
// returns. Mail errors are caught so they don't fail the request.
await sendSubscriptionConfirmationEmail({ to: input.email }).catch(
(err) =>
emailLog("error", "email.catch", {
type: "subscription_confirmation",
to: input.email,
error: String(err),
}),
);
return { ok: true };