feat(notificaciones): mass email notifications over SES

Replaces the four legacy PHP scripts under email.notifications/send*.php
with a single NestJS module. Four jobs (outstanding payments, payment
confirmations, account-status alerts with day-of-week gates, trust
payment confirmations) share one MailService modelled on StorageService:
env-driven SES client, null fallback in dev with console logging, refuses
to send in production when unconfigured.

Schema adds email_notification_log (every attempt, sent/failed/skipped)
and account_status_history (one row per threshold hit, Job 3). Enums
encode the legacy wire shape so external log scrapers keep parsing
notificationType keys verbatim.

Web adds /notificaciones with four trigger cards, a flags panel, and a
paginated log browser. New notification:send ability gates all four
endpoints at MANAGER, matching the renewal:send trust tier.
This commit is contained in:
2026-08-02 02:04:14 -07:00
parent 5e9cb12fba
commit a52e59cbc5
21 changed files with 3128 additions and 4 deletions
+7 -1
View File
@@ -38,7 +38,8 @@ export type Ability =
| "statement:review"
| "lookup:manage"
| "user:manage"
| "db:manage";
| "db:manage"
| "notification:send";
/** Minimum role required for each ability. */
export const ABILITY_MIN: Record<Ability, Role> = {
@@ -71,6 +72,11 @@ export const ABILITY_MIN: Record<Ability, Role> = {
"lookup:manage": "MANAGER",
"user:manage": "ADMIN",
"db:manage": "ADMIN",
// Mass email notifications — fires mail to customers on the office's
// behalf, with no per-row review. Same trust tier as `renewal:send`:
// a STAFF user typing one customer receipt is fine; a STAFF user firing
// 260 mail merges on the customer base is not.
"notification:send": "MANAGER",
};
export const ALL_ABILITIES = Object.keys(ABILITY_MIN) as Ability[];