diff --git a/backend/src/handlers/auth/custom-message-trigger.ts b/backend/src/handlers/auth/custom-message-trigger.ts new file mode 100644 index 0000000..f84da8a --- /dev/null +++ b/backend/src/handlers/auth/custom-message-trigger.ts @@ -0,0 +1,45 @@ +import type { CustomMessageTriggerEvent } from 'aws-lambda'; +import { renderEmailLayout } from '../../services/email-layout'; + +function codeBadgeHtml(code: string): string { + return `
Thanks for signing up. Enter this code to verify your email address:
${codeBadgeHtml(code)}If you didn't create a Muster account, you can safely ignore this email.
`, + bodyText: `Enter this code to verify your email address: ${code}\n\nIf you didn't create a Muster account, you can safely ignore this email.`, + }); + event.response.emailSubject = 'Verify your Muster account'; + event.response.emailMessage = html; + return event; + } + + if (event.triggerSource === 'CustomMessage_ForgotPassword') { + const { html } = renderEmailLayout({ + eyebrow: 'Password reset', + heading: 'Reset your Muster password', + bodyHtml: `Use this code to choose a new password:
${codeBadgeHtml(code)}If you didn't request a password reset, you can safely ignore this email.
`, + bodyText: `Use this code to choose a new password: ${code}\n\nIf you didn't request a password reset, you can safely ignore this email.`, + }); + event.response.emailSubject = 'Reset your Muster password'; + event.response.emailMessage = html; + return event; + } + + return event; +}; diff --git a/backend/src/lib/date-format.ts b/backend/src/lib/date-format.ts new file mode 100644 index 0000000..fff348f --- /dev/null +++ b/backend/src/lib/date-format.ts @@ -0,0 +1,15 @@ +const formatter = new Intl.DateTimeFormat('en-US', { + weekday: 'short', + month: 'short', + day: 'numeric', + year: 'numeric', + hour: 'numeric', + minute: '2-digit', + timeZone: 'UTC', + timeZoneName: 'short', +}); + +/** Renders an ISO date string for email copy, e.g. "Tue, Sep 1, 2026, 9:00 AM UTC". */ +export function formatEmailDate(iso: string): string { + return formatter.format(new Date(iso)); +} diff --git a/backend/src/lib/validation.ts b/backend/src/lib/validation.ts index c2bcd3c..3bec13d 100644 --- a/backend/src/lib/validation.ts +++ b/backend/src/lib/validation.ts @@ -69,6 +69,7 @@ export const createEventSchema = z endDate: isoDateSchema, capacity: z.number().int().min(0).max(1_000_000), ticketLink: urlSchema, + imageUrl: urlSchema, }) .refine((data) => Date.parse(data.endDate) >= Date.parse(data.startDate), { message: 'endDate must be on or after startDate.', diff --git a/backend/src/models/types.ts b/backend/src/models/types.ts index 81c9919..b47d2af 100644 --- a/backend/src/models/types.ts +++ b/backend/src/models/types.ts @@ -21,6 +21,7 @@ export interface EventRecord { capacity: number; registeredCount: number; ticketLink: string; + imageUrl?: string; status: EventStatus; rejectionReason?: string; createdAt: string; diff --git a/backend/src/services/email-layout.ts b/backend/src/services/email-layout.ts new file mode 100644 index 0000000..44effe8 --- /dev/null +++ b/backend/src/services/email-layout.ts @@ -0,0 +1,83 @@ +/** + * Shared HTML shell for outbound email. Table-based markup with inline + * styles only — the notification dispatcher Lambda sends this straight + * through SES with no further processing, and inboxes (Outlook's Word + * rendering engine especially) don't reliably support