L6 Benachrichtigungen & Audit: Empfängerregeln, In-App-Benachrichtigungen und Craftvia-Mails

- handleEvent (Signatur unverändert) löst alle 17 Domain-Events auf: Team/Assignees,
  Backoffice (read_all + report:approve), Teamleiter-Freigaben, Ersteller, Abrechnung,
  Notdienst, Import, Sync; Akteur ausgenommen, alle IDs über ctx.db neu aufgelöst.
- In-App-Notification über ctx.db (ungelesene gleiche Meldung wird aufgefrischt),
  E-Mail über enqueueMail mit dedupeKey event:entity:user (+ optional occurrenceId),
  Opt-out je Typ, Notdienst als Pflichtmail, feste Empfänger ohne Doppelmail.
- Mail-Templates craftvia_* (de/en) inkl. Notdienst-Format Spec §19.4 und Craftvia-Fußzeile.
- Migration tenant_mail_settings: mailFromName, mailReplyTo, emergencyRecipients,
  billingRecipients an tenant_settings (keine neue Tabelle).
- Texte aus messages/{de,en}/notifications.json.
- Test scripts/test-benachrichtigungen-events.ts (63 Prüfungen).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-14 12:11:53 +02:00
co-authored by Claude Opus 5
parent bf4456718e
commit 7b37c41a83
9 changed files with 1452 additions and 4 deletions
@@ -0,0 +1,9 @@
-- L6 Benachrichtigungen: Mandanten-Mailkonfiguration (Spec §33.2).
-- Nur neue Spalten an tenant_settings (Tabelle ist bereits mandantengebunden/RLS), keine neue Tabelle.
-- Absenderadresse bleibt Plattform-Domain (SPF/DKIM); je Mandant nur Anzeigename und Reply-To.
-- AlterTable
ALTER TABLE "tenant_settings" ADD COLUMN "billing_recipients" TEXT[] DEFAULT ARRAY[]::TEXT[],
ADD COLUMN "emergency_recipients" TEXT[] DEFAULT ARRAY[]::TEXT[],
ADD COLUMN "mail_from_name" TEXT,
ADD COLUMN "mail_reply_to" TEXT;