Notification e-mail now defaults to the clearly arranged layout of #5171 - board first, board, actor and card in bold and linked, with a plain-text alternative. One sentence (classic) is still one choice away at the Admin Panel, board and member levels, and the tray keeps the classic line. Account e-mails - reset password, verify e-mail, enroll account, and the board and registration invitations - get an HTML part in the same style, built from the same translated text, which is still sent as the text part: no translation changes. Every piece of text is escaped first, the link paragraph becomes a button, and only an http(s) address is linked. A caller's own HTML and texts that are not WeKan's e-mail strings are left as they were, and a failure to build the HTML leaves the text alone. models/lib/accountEmailHtml.js renders it; tests/accountEmailHtml.test.cjs lays out the real English texts and checks that markup in a name, a board title or the site name stays text and only http(s) is linked. notificationDelivery's default assertions now expect clear for e-mail, and emailLocalizationPreparation's harness allows the new module, checks the HTML part, and checks the absent-HTML case with literal text. Thanks to Meeques and xet7 ! Fixes #4434.
8.2 KiB
Notification delivery: content, grouping and schedule
Issues: #3695 (what webhooks send), #5171 (clearly arranged, combined e-mails).
Every notification channel - e-mail, the notification tray (the bell) and outgoing webhooks - has the same three kinds of settings:
- Content - what one notification shows.
- Grouping - one message per notification, or several combined.
- Schedule - when it is delivered: immediately, every N minutes/hours, or once a day, with optional quiet hours.
One shared, pure module resolves and applies them for every channel:
models/lib/notificationDelivery.js. Each channel only adapts its output.
The built-in behaviour
With nothing set anywhere, every channel behaves as below. E-mail is in the clearly arranged layout since #4434; everything else is what WeKan always did:
| Channel | Built-in behaviour |
|---|---|
the clearly arranged layout, with a plain-text alternative; everything due for a recipient combined into one e-mail, sent EMAIL_NOTIFICATION_TIMEOUT (30 s) after the notification |
|
| Tray | the classic activity line; every notification its own entry, shown at once |
| Webhook | text plus the standard attributes (WEBHOOKS_ATTRIBUTES); one POST per notification, at once |
Where to set it, and which setting wins
The Notifications popup has a section per channel (Email, Notifications tray, Outgoing Webhooks), opened from:
- Admin Panel → People → Notifications: the instance defaults (instance admins);
- Board Settings → Notifications: this board's settings (board admins);
- Member Settings → Notifications: the member's own e-mail and tray;
- each webhook's own form (Board Settings → Outgoing Webhooks, Admin Panel → Settings → Global Webhooks): that webhook.
Each key (layout, parts, grouping, schedule, interval, time, quiet hours) is resolved on its own; the most specific level that sets it wins:
E-mail, tray: Member Settings -> Board -> Admin Panel -> built-in
Webhooks: the webhook -> Board -> Admin Panel -> built-in
- The board level applies to that board's notifications, and for webhooks only to the board's own webhooks: a global webhook belongs to the instance administrator, so a board admin cannot reshape it.
- A member cannot change a board's webhook delivery. What a member owns there is their identity: Leave my name out of outgoing webhooks (see Webhook data).
- "Default" (board, member, webhook) clears that level's value so it inherits.
All settings are saved through one server method,
setNotificationDelivery(scope, targetId, channel, settings)
(server/methods/notificationDelivery.js). It accepts only the known keys and
values, and only from the right role: instance admins for the Admin Panel and
global webhooks, the board's admins (or an instance admin) for a board and its
webhooks, and a member only for their own profile. The database schemas carry
the same allowed values, so a direct document write cannot store anything else.
Content
E-mail and tray: layout and parts
Layout: One sentence (classic) is the sentence WeKan always sent:
NAME created card "TEst" to list "To Do" at swimlane Social Network at board "Projekt Teilbereich C" LINK
Clearly arranged puts the board first and the board, the actor and the card in bold, with links (#5171), showing only the chosen parts:
[Projekt Teilbereich C](board link): NAME created card ["TEst"](card link) to list "To Do"
| Part | Shows |
|---|---|
board |
the board name, linked, at the start of the item |
actor |
who did it |
card |
the card title as a link to the card |
list |
the list (and the previous list of a move) |
swimlane |
the swimlane |
details |
the comment text or the changed value |
dates |
the dates of a date change |
link |
the link on a line of its own, as in the classic layout |
A part that is switched off removes its clause from the sentence ("at swimlane ...") in any language, as long as the clause is joined by a short connector; where removing it would break the sentence the value stays. E-mail in the clear layout also carries a plain-text alternative of every item.
An admin's own activity e-mail template (Admin Panel → Email Templates) still wins over the layout: it is the more specific instruction.
E-mail uses Clearly arranged unless a level chooses One sentence (classic) (#4434); the tray keeps the classic line. Account e-mails - reset password, verify e-mail, a new account and board invitations - are sent in the same clear HTML style, built from the same translated text, which is also sent as their plain-text part.
Webhooks
Send the message text and Send these fields - see Webhook data for every property.
What is never shown
- A notification only reaches a member of the board who may see it (the existing recipient rules, re-checked when a queued e-mail is sent).
- The value of an admin-only custom field (#3141) reaches only the board's admins - in e-mail and the tray, in both layouts - and never a webhook.
- Every user-written value (titles, names, comments) is HTML-escaped, and a
link is made only from an
http(s)URL.
Grouping
| Channel | Options |
|---|---|
| Everything due in one e-mail (built-in), one per board, one per card, each on its own | |
| Tray | Each on its own (built-in), one row per card, one row per board ("3 notifications on card X", expandable) |
| Webhook | Each on its own (built-in), everything in one POST, one per board, one per card |
A grouped webhook POST is
{ "text": "...", "description": "act-batch", "count": 3, "items": [ ... ] },
each item the body a single notification would have sent; a group of one is
sent as that single body. Grouping waits a short window (30 s) when the
schedule is Immediately, so notifications that arrive together go together.
Schedule
- Immediately - the built-in timing above.
- Every N minutes/hours (5, 10, 15, 30 minutes; 1, 2, 4, 8, 12, 24 hours) - delivered at the next boundary of the local clock (for one hour: on the hour), so everything inside one window is delivered, and grouped, together.
- Once a day at a chosen time.
- Quiet hours (from - to, may span midnight) - anything that would be delivered inside them waits until they end.
Times are in the time zone saved with the setting: the browser's time zone of whoever set it (shown under the setting), UTC if none.
Durable, exactly-once delivery
- E-mail uses the existing durable outbox (
server/lib/emailOutbox.js): each notification is a stored job with its delivery time before anything is sent; one e-mail carries the jobs of one group; a job is marked sent only after the mail server accepted it. A restart in a window loses nothing, and a stored job keeps its time when a setting changes later. - Tray: the entry is stored at once with a
showAttime; the drawer and the bell show it when the time comes. Nothing is waiting in memory. - Webhooks: a grouped or scheduled webhook notification is stored in the
webhook queue (
server/lib/webhookOutbox.js,server/notifications/webhookQueue.js) and POSTed to the webhook as it is at delivery (a deleted or disabled webhook cancels it; the current URL and token are used). It is marked sent after a 2xx answer and retried with backoff otherwise. Like e-mail, a crash between the HTTP answer and the acknowledgement can repeat that one request (at-least-once). - Two-way webhooks are always immediate: their reply edits the comment the
event was about. Webhooks planned by board Sync (
server/notifications/ prepareWebhooks.js, stored plans with their own delivery receipts) are delivered immediately too, with the content settings applied.