Webhook channels can send a templated body for push and chat services, and any channel can send a test #154

Open
opened 2026-10-31 12:42:16 -04:00 by claude · 0 comments
Owner
  • Draft: PN-16
  • Priority: high
  • Agent: coder
  • Depends on: #151
  • Decisions: Q-PN-7

Why

Push and chat services need their own body shape; today every subscriber gets one fixed envelope.

What changes

  • New NotificationTemplateRenderer in src/dotnet/src/Ninlil.Dns.Server.Notifications/. It replaces {{event.<property>}} (the event's camelCase JSON properties), {{eventType}}, {{occurredAtUtc}} and {{server.hostName}} (Environment.MachineName). An escaping mode (Json, Html, None) applies to every substituted value. Validate(template, mode) returns the unknown placeholders.
    • Technical call: plain placeholder substitution with no expressions, loops or third-party template engine, so a template cannot run code.
  • Rename WebhookDeliveryService to NotificationDeliveryService. It finds matching enabled channels of every kind, builds the payload per channel (a template differs per channel, where today one body serves all, WebhookDeliveryService.cs:136-142) and hands it to an INotificationChannelSender chosen by Kind.
  • New WebhookChannelSender holds today's HTTP attempt (WebhookDeliveryService.cs:396-455, auth header at 483-514). With no PayloadTemplate the body is today's envelope (BuildPayload, lines 547-563); with one, the rendered template, JSON-escaped when the content type is JSON. Content-Type comes from PayloadContentType (default application/json). The HMAC signature (SignatureHeaderName, line 84) covers the rendered body.
  • NotificationDeliveryService.SendTestAsync(channel, stoppingToken) renders a synthetic event of the first subscribed type (or DnsZoneChanged when none), sends once through the kind's sender, saves no delivery row and returns the outcome.

Acceptance

  • This test fails first: Deliver_WithATemplate_PostsTheRenderedBody in src/dotnet/tests/Ninlil.Dns.Server.Notifications.Tests (fake HTTP handler; asserts the body {"topic":"ninlil","message":"Zone example.com changed"}).
  • Tests: JSON escaping of quotes; signature over the rendered body; a channel without a template still gets today's envelope; Validate reports {{event.nope}}; SendTestAsync saves no row.
  • Gate: dotnet test src/dotnet/tests/Ninlil.Dns.Server.Notifications.Tests, dotnet test src/dotnet/tests/Ninlil.Web.Tests.

Source

audit-feature-parity.md §2A #12.
Owner decision 2026-10-31: Q-PN-7.

- **Draft:** PN-16 - **Priority:** high - **Agent:** coder - **Depends on:** #151 - **Decisions:** Q-PN-7 ### Why Push and chat services need their own body shape; today every subscriber gets one fixed envelope. ### What changes - New `NotificationTemplateRenderer` in `src/dotnet/src/Ninlil.Dns.Server.Notifications/`. It replaces `{{event.<property>}}` (the event's camelCase JSON properties), `{{eventType}}`, `{{occurredAtUtc}}` and `{{server.hostName}}` (`Environment.MachineName`). An escaping mode (`Json`, `Html`, `None`) applies to every substituted value. `Validate(template, mode)` returns the unknown placeholders. - Technical call: plain placeholder substitution with no expressions, loops or third-party template engine, so a template cannot run code. - Rename `WebhookDeliveryService` to `NotificationDeliveryService`. It finds matching enabled channels of every kind, builds the payload per channel (a template differs per channel, where today one body serves all, `WebhookDeliveryService.cs:136-142`) and hands it to an `INotificationChannelSender` chosen by `Kind`. - New `WebhookChannelSender` holds today's HTTP attempt (`WebhookDeliveryService.cs:396-455`, auth header at 483-514). With no `PayloadTemplate` the body is today's envelope (`BuildPayload`, lines 547-563); with one, the rendered template, JSON-escaped when the content type is JSON. Content-Type comes from `PayloadContentType` (default `application/json`). The HMAC signature (`SignatureHeaderName`, line 84) covers the rendered body. - `NotificationDeliveryService.SendTestAsync(channel, stoppingToken)` renders a synthetic event of the first subscribed type (or `DnsZoneChanged` when none), sends once through the kind's sender, saves no delivery row and returns the outcome. ### Acceptance - [ ] This test fails first: `Deliver_WithATemplate_PostsTheRenderedBody` in `src/dotnet/tests/Ninlil.Dns.Server.Notifications.Tests` (fake HTTP handler; asserts the body `{"topic":"ninlil","message":"Zone example.com changed"}`). - [ ] Tests: JSON escaping of quotes; signature over the rendered body; a channel without a template still gets today's envelope; `Validate` reports `{{event.nope}}`; `SendTestAsync` saves no row. - [ ] Gate: `dotnet test src/dotnet/tests/Ninlil.Dns.Server.Notifications.Tests`, `dotnet test src/dotnet/tests/Ninlil.Web.Tests`. ### Source `audit-feature-parity.md` §2A #12. Owner decision 2026-10-31: Q-PN-7.
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#154
No description provided.