feat(erinnerungen): e-mail, wenn ein wunschlisten-termin naeher rueckt

Ruecken Termin und offene Wuensche zusammen, geht eine Nachricht an den
Besitzer der Liste - standardmaessig 14 Tage vorher, hoechstens einmal
pro Woche je Liste. Ist alles reserviert, bleibt es still: eine
Erinnerung ohne Handlungsbedarf ist nur Laerm.

Der Zeitplan haengt an Next' instrumentation-Hook und prueft stuendlich,
nicht taeglich - so kann ein Neustart keinen Tag ueberspringen, und die
Sperrfrist je Liste verhindert trotzdem Mehrfachversand. Der Zeitstempel
wird erst nach erfolgreichem Versand gesetzt, damit ein Fehlversuch
wiederholt wird.

Ohne SMTP_HOST und SMTP_FROM ist die Funktion komplett aus: kein
Zeitplan, kein Versand, und die Verwaltungsseite erklaert stattdessen,
was in die .env gehoert. Mit Konfiguration gibt es dort Knoepfe fuer
Verbindungstest, Testnachricht und sofortige Pruefung.

12 Tests fuer die Entscheidungsregeln. Einer davon hat einen echten
Fehler gefunden: die Sperrfrist rechnete mit umgedrehtem Vorzeichen und
haette jede Erinnerung dauerhaft unterdrueckt.

Refs Phase 3

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
unknown
2026-09-07 09:22:29 +02:00
co-authored by Claude Opus 5
parent 91fb66b13b
commit 0d08df0bff
17 changed files with 2884 additions and 1 deletions
+22 -1
View File
@@ -27,8 +27,26 @@ const schema = z.object({
/** Upload size limit per file, in megabytes. */
MAX_UPLOAD_MB: z.coerce.number().int().positive().max(200).default(25),
/** Optional, phase 2: Rebrickable set import. Import stays disabled without it. */
/** Optional: Rebrickable set import. Import stays disabled without it. */
REBRICKABLE_API_KEY: z.string().min(1).optional(),
/**
* Optional: outgoing mail for wishlist reminders. Without SMTP_HOST the
* whole reminder feature stays switched off - nothing is scheduled, nothing
* is sent.
*/
SMTP_HOST: z.string().min(1).optional(),
SMTP_PORT: z.coerce.number().int().min(1).max(65535).default(587),
SMTP_SECURE: z
.enum(['true', 'false'])
.default('false')
.transform((value) => value === 'true'),
SMTP_USER: z.string().min(1).optional(),
SMTP_PASSWORD: z.string().min(1).optional(),
SMTP_FROM: z.string().min(1).optional(),
/** How many days before the event a reminder goes out. */
REMINDER_DAYS_BEFORE: z.coerce.number().int().min(1).max(90).default(14),
});
/**
@@ -82,6 +100,9 @@ export const env = {
MAX_UPLOAD_BYTES: raw.MAX_UPLOAD_MB * 1024 * 1024,
isProduction: raw.NODE_ENV === 'production',
/** Reminders need a host and a sender; everything else has a default. */
isMailConfigured: Boolean(raw.SMTP_HOST && raw.SMTP_FROM),
} as const;
export type Env = typeof env;