Skip to main content

Module notifications

Module notifications 

Source
Expand description

Notifications (decisions 408-429): which channels hear of an event, the message each gets, and the checks on a DAG’s notify=.

An event queues one notification per channel told of it, in the transaction that records the event (the outbox, decision 410); sender delivers them. A body is filled here, when it is queued, from fixed values (Placeholder): nothing in it is code.

Modules§

sender
The master’s sender: delivers the outbox (decision 410). A notification delivered is deleted; one that fails is tried again later, waiting longer each time, until [notifications] give_up_after has passed since it was queued: then it is logged as an error, counted and deleted. Redirects aren’t followed (decision 425), and a URL is never logged (a server webhook’s may hold its secret).

Structs§

Budget
What a body may still take, in bytes of its JSON, as it is filled: each value is measured before it is copied, so a template using a big value many times stops at the limit instead of filling the master’s memory (Codex’s review of M4.13a).
EmailChannel
A server email channel (type = "email"): its recipients, every one in To.
Event
What happened, for the message.
Notifications
The notification settings ([notifications]), checked.
ServerWebhook
A server webhook, its headers read from the environment.
Smtp
The mail server ([notifications.smtp]), checked.

Constants§

DEFAULT_MAX_BODY
The most bytes a filled body may take by default (1 MiB).
KIND_EMAIL
A notification sent as an email; its body holds to, subject and text.
KIND_WEBHOOK
A notification posted to a webhook (notifications.kind).
MAX_FAILED_TASKS
The most failed tasks a message lists.
MESSAGE
The event name of a message a task sends itself.

Functions§

fill
body filled from vars, within budget. With strict (a task’s own send), a path into data that the data lacks is an error; otherwise it fills as null (empty in text).
url_within
Whether url is within allowed (decision 425): the same scheme, host and port, no user or password, and a path under allowed’s, at a / (https://a.example.com/hooks allows /hooks and /hooks/x, not /hooksy). Both are parsed, as the client parses them, so a host suffix (a.example.com.evil) or userinfo (a.example.com@127.0.0.1) can’t pass.