How does hAPI send notifications through ntfy? #69
Notifications
Due Date
No due date set.
Depends on
Reference: bobby/hapi#69
Reference in new issue
Block a user
Part of #44
Question
Which notifications ship in v1, who sends each (hAPI, CI, Flux, vmalert, Kuma), how they're routed to Persons or the Household (topics, priorities), how hAPI authenticates to ntfy, and whether Persons can opt out or choose where notifications go?
Context carried from the map: a shared notification capability; topics, per-Person routing, auth to ntfy (hAPI's ntfy token is its own narrow credential delivered through SOPS, separate from CI's publish-only token, per ADR-0008). Depends on domain MVPs and data ownership. Candidates: alert the Household when
hapi db breakglassis used; warn Principals about Tokens nearing expiry (ADR-0005); notify the Household when a Job fails or expires (ADR-0006); notify the Owner of CI workflow failures (anif: failure()step) and of Flux reconcile or rollout failures (ADR-0007). vmalert is a sender too (ADR-0009), and Kuma's down and degraded monitors want different priorities. Maintenance: notify the Household when a Task becomes due or overdue, honouring per-Tasklead_days; the trigger must be event-driven as well as scheduled, since a new Reading can make a usage-based Task due. Finance: a month-end nudge when a Budget can be rebalanced (a Category in the red while another has money left), and a warning when an importer Bot's Transactions stop arriving.From How do scheduled and background jobs run? (ADR-0012): checks are CronJobs running
hapi notify <check>(pool 1, run as theschedulerBot for Household data or per Person read-only for Personal data). They write durable Notification records (glossary: Notification) that also serve as the dedupe ledger. Undelivered ones are retried on the next run. Event-triggered cases (a new Reading) are caught by the next check. Decide here: the Notification's fields and recipients, channels and per-recipient channel preferences (ntfy now, a frontend inbox later, or both), whether v1 stores read state, check intervals, and whether delivery runs inside each check or in its own CronJob.Resolution
Recorded in ADR-0013; glossary Notification sharpened.
ops; Kuma down + Watchdog →ops-urgent) publish straight to ntfy, Owner-only, never via hAPI. hAPI Notifications are records addressed to one Person or the Household.hapi-p-<id>,hapi-household), one publish-only user per sender.upstream-base-url→ ntfy.sh (iOS), 12 h cache, no attachments. Content = short title + link, no amounts or Personal data.tasksdaily 08:00 (due-soon, overdue, once per occurrence);jobsevery 15 min (failed/expired);budgethourly (Household Category goes into the red; refires only after recovering; replaces the month-end nudge);tokensdaily (30/7 days, to the Person or to the Owner for Bot Tokens). No importer-staleness check: ADR-0011 failure onerrors+ Kuma cover it.hapi notify deliverevery 2 min is the sole publisher, idempotent on Notification id, gives up at 24 h (vmalert rule). Breakglass publishes synchronously and refuses to start if that fails.kind,dedupe_key(unique with kind), title, body, priority, link,delivered_at,attempts; delivered rows purged after 180 d. No preferences, read state or API in v1; opt out by muting in ntfy.