One notification-channel model replaces webhook subscriptions and delivers alerts by templated webhook and e-mail #149

Open
opened 2026-10-31 12:42:15 -04:00 by claude · 0 comments
Owner
  • Draft: PN-12
  • Priority: high (alerts from #160 are useless without delivery to a person)
  • Agent: none (epic)
  • Depends on: none
  • Decisions: Q-PN-7, Q-PN-8, R2-WEBHOOKS, R2-RENAME

Why

Webhooks post one fixed JSON shape (WebhookDeliveryService.BuildPayload, src/dotnet/src/Ninlil.Dns.Server.Webhooks/WebhookDeliveryService.cs:547-563). WebhookSubscriptionEntity has no template field (src/dotnet/src/Ninlil.Dns.Data.Abstractions/Entity/WebhookSubscriptionEntity.cs:13-72), so ntfy, Gotify, Discord or Slack cannot receive a readable message. SMTP exists only for identity mail (src/dotnet/src/Ninlil.Dns.Identity/Email/SmtpEmailSender.cs:29, IEmailSender.cs:9-23). The owner chose one channel entity for every delivery kind, so a later kind (MQTT, for example) is a new value, not a new table.

What changes

The design, in one place so every child agrees:

  • Entity. NotificationChannelEntity (table NinlilDnsNotificationChannels) replaces WebhookSubscriptionEntity. Common fields: Name (unique), Kind (NotificationChannelKindEnum: Webhook, Email), EventTypeNames, MaxDeliveryAttempts, IsDisabled, Comments. Webhook fields (null for other kinds): TargetUrl, AuthMode, AuthCredentialsEncrypted, HmacSigningSecretEncrypted, PayloadTemplate, PayloadContentType. E-mail fields (null for other kinds): EmailRecipients, EmailSubjectTemplate, EmailBodyTemplate.
    • Technical call: typed nullable columns, not a JSON settings blob. Each kind keeps database-side validation and plain Mongo class maps, and the API validates per kind.
  • History. NotificationDeliveryEntity (table NinlilDnsNotificationDeliveries) replaces WebhookDeliveryAttemptEntity for every kind: ChannelId, ChannelName, ChannelKind, EventTypeName, Payload (the rendered body, captured once as today, WebhookDeliveryAttemptEntity.cs:49-54) and the existing status and retry fields.
  • Migration of existing webhook subscriptions. Every subscription becomes a Webhook channel with the same Id, so its delivery history keeps pointing at it. Stored role and user claims move to the new permission names: webhooks:read/webhooks:write become notifications:read/notifications:write, and webhookdeliverysettings:read/webhookdeliverysettings:write become notificationdeliverysettings:read/notificationdeliverysettings:write. Older backup archives restore as webhook channels.
  • Delivery. One engine (NotificationDeliveryService) with one sender per kind, the existing persisted retry sweep for every kind, and one placeholder renderer for templates.
  • E-mail retries (Q-PN-8, best effort). An e-mail channel allows at most two attempts (one attempt plus one retry), and the last error shows in its delivery history.
  • API (R2-WEBHOOKS). api/notification-channels replaces api/webhooks, which is removed in the same release (#156) with no deprecated alias.
  • Renamed, no aliases (R2-RENAME). The operator-facing webhook names move to notification names in #152, with no alias for the old ones:
    • variables NINLIL_DNS_SERVER_WEBHOOKS_DELIVERY_* (section DnsServer:Webhooks:Delivery, src/dotnet/src/Ninlil.Dns.Server.Webhooks/WebhookDeliveryOptions.cs:19; ENVIRONMENT.md:468-472) become NINLIL_DNS_SERVER_NOTIFICATIONS_DELIVERY_* (section DnsServer:Notifications:Delivery);
    • route api/webhook-delivery-settings (src/dotnet/src/Ninlil.Web/Controllers/WebhookDeliverySettingsController.cs:38) becomes api/notification-delivery-settings;
    • managed-service id webhook-delivery-retry-sweep (src/dotnet/src/Ninlil.Web/Services/ManagedServiceRegistry.cs:309) becomes notification-delivery-retry-sweep;
    • health component webhookDelivery (src/dotnet/src/Ninlil.Web/Program.cs:712) becomes notificationDelivery.
  • Kept. Channels stay node-local, as webhook subscriptions are today (README.md:4059). MQTT stays out of scope (audit: defer).

Children, in order:

  • #150: mechanic, project rename (no behaviour change)
  • #151: storage, channel and delivery entities, migrations, Mongo step, permission claims
  • #152: operator-facing names: delivery settings section, variables, route, sweep id, health check
  • #153: backup restore of older archives
  • #154: template renderer, templated webhooks, test send
  • #155: e-mail channel kind
  • #156: REST API, removal of api/webhooks, README
  • #157: snapshot and client regeneration
  • #158: console channels pages (replace the webhook pages)
  • #159: console template editor, presets and test button

Acceptance

  • Children #150 to #158, #159 and #152 closed.
  • A database upgraded from the first release keeps every webhook subscription as a working webhook channel on every engine.
  • README.md has a "Notifications" section with ntfy and Discord examples; CHANGELOG Unreleased lists the removed route and every renamed name.

Source

audit-feature-parity.md §2A #12.
Owner decision 2026-10-31: "ONE UNIFIED notification-channel entity (replaces webhook subscriptions)" (Q-PN-7); "mail retry: best effort" (Q-PN-8).
Owner decisions 2026-10-31, round 2: "api/webhooks: remove now, no deprecated alias" (R2-WEBHOOKS); "webhook delivery env vars, route, sweep id, health check: rename to notifications, no aliases" (R2-RENAME).

- **Draft:** PN-12 - **Priority:** high (alerts from #160 are useless without delivery to a person) - **Agent:** none (epic) - **Depends on:** none - **Decisions:** Q-PN-7, Q-PN-8, R2-WEBHOOKS, R2-RENAME ### Why Webhooks post one fixed JSON shape (`WebhookDeliveryService.BuildPayload`, `src/dotnet/src/Ninlil.Dns.Server.Webhooks/WebhookDeliveryService.cs:547-563`). `WebhookSubscriptionEntity` has no template field (`src/dotnet/src/Ninlil.Dns.Data.Abstractions/Entity/WebhookSubscriptionEntity.cs:13-72`), so ntfy, Gotify, Discord or Slack cannot receive a readable message. SMTP exists only for identity mail (`src/dotnet/src/Ninlil.Dns.Identity/Email/SmtpEmailSender.cs:29`, `IEmailSender.cs:9-23`). The owner chose one channel entity for every delivery kind, so a later kind (MQTT, for example) is a new value, not a new table. ### What changes The design, in one place so every child agrees: - **Entity.** `NotificationChannelEntity` (table `NinlilDnsNotificationChannels`) replaces `WebhookSubscriptionEntity`. Common fields: `Name` (unique), `Kind` (`NotificationChannelKindEnum`: `Webhook`, `Email`), `EventTypeNames`, `MaxDeliveryAttempts`, `IsDisabled`, `Comments`. Webhook fields (null for other kinds): `TargetUrl`, `AuthMode`, `AuthCredentialsEncrypted`, `HmacSigningSecretEncrypted`, `PayloadTemplate`, `PayloadContentType`. E-mail fields (null for other kinds): `EmailRecipients`, `EmailSubjectTemplate`, `EmailBodyTemplate`. - Technical call: typed nullable columns, not a JSON settings blob. Each kind keeps database-side validation and plain Mongo class maps, and the API validates per kind. - **History.** `NotificationDeliveryEntity` (table `NinlilDnsNotificationDeliveries`) replaces `WebhookDeliveryAttemptEntity` for every kind: `ChannelId`, `ChannelName`, `ChannelKind`, `EventTypeName`, `Payload` (the rendered body, captured once as today, `WebhookDeliveryAttemptEntity.cs:49-54`) and the existing status and retry fields. - **Migration of existing webhook subscriptions.** Every subscription becomes a `Webhook` channel with the same `Id`, so its delivery history keeps pointing at it. Stored role and user claims move to the new permission names: `webhooks:read`/`webhooks:write` become `notifications:read`/`notifications:write`, and `webhookdeliverysettings:read`/`webhookdeliverysettings:write` become `notificationdeliverysettings:read`/`notificationdeliverysettings:write`. Older backup archives restore as webhook channels. - **Delivery.** One engine (`NotificationDeliveryService`) with one sender per kind, the existing persisted retry sweep for every kind, and one placeholder renderer for templates. - **E-mail retries (Q-PN-8, best effort).** An e-mail channel allows at most two attempts (one attempt plus one retry), and the last error shows in its delivery history. - **API (R2-WEBHOOKS).** `api/notification-channels` replaces `api/webhooks`, which is removed in the same release (#156) with no deprecated alias. - **Renamed, no aliases (R2-RENAME).** The operator-facing webhook names move to notification names in #152, with no alias for the old ones: - variables `NINLIL_DNS_SERVER_WEBHOOKS_DELIVERY_*` (section `DnsServer:Webhooks:Delivery`, `src/dotnet/src/Ninlil.Dns.Server.Webhooks/WebhookDeliveryOptions.cs:19`; `ENVIRONMENT.md:468-472`) become `NINLIL_DNS_SERVER_NOTIFICATIONS_DELIVERY_*` (section `DnsServer:Notifications:Delivery`); - route `api/webhook-delivery-settings` (`src/dotnet/src/Ninlil.Web/Controllers/WebhookDeliverySettingsController.cs:38`) becomes `api/notification-delivery-settings`; - managed-service id `webhook-delivery-retry-sweep` (`src/dotnet/src/Ninlil.Web/Services/ManagedServiceRegistry.cs:309`) becomes `notification-delivery-retry-sweep`; - health component `webhookDelivery` (`src/dotnet/src/Ninlil.Web/Program.cs:712`) becomes `notificationDelivery`. - **Kept.** Channels stay node-local, as webhook subscriptions are today (README.md:4059). MQTT stays out of scope (audit: defer). Children, in order: - #150: mechanic, project rename (no behaviour change) - #151: storage, channel and delivery entities, migrations, Mongo step, permission claims - #152: operator-facing names: delivery settings section, variables, route, sweep id, health check - #153: backup restore of older archives - #154: template renderer, templated webhooks, test send - #155: e-mail channel kind - #156: REST API, removal of `api/webhooks`, README - #157: snapshot and client regeneration - #158: console channels pages (replace the webhook pages) - #159: console template editor, presets and test button ### Acceptance - [ ] Children #150 to #158, #159 and #152 closed. - [ ] A database upgraded from the first release keeps every webhook subscription as a working webhook channel on every engine. - [ ] README.md has a "Notifications" section with ntfy and Discord examples; CHANGELOG `Unreleased` lists the removed route and every renamed name. ### Source `audit-feature-parity.md` §2A #12. Owner decision 2026-10-31: "ONE UNIFIED notification-channel entity (replaces webhook subscriptions)" (Q-PN-7); "mail retry: best effort" (Q-PN-8). Owner decisions 2026-10-31, round 2: "api/webhooks: remove now, no deprecated alias" (R2-WEBHOOKS); "webhook delivery env vars, route, sweep id, health check: rename to notifications, no aliases" (R2-RENAME).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#149
No description provided.