Files
straiforosandTangled fcd2030275 feat(custom-templates): Add notification templates capability for customizes notifications with examples
- use tranquil_pds not comms since the validate email and templates are reexported from pds package
- implement handlebars syntax
- update templates to be transport agnostic, email, discord, telegram with handlebar examples with conditions
- refactor template and notice logic from PR #269, and #299 to be self contained enforcing all substitutions to be defined within the enum properties
- fix open TODOs, store.rs uses get_string within the ids.rs get_built_ins method
- UTC logging for User facing notices restored
- new api error for verification channel requires bot
- fix tests to use metadata for html body...
- remove unwrap and handle template rendering error explicitly
- update verify_link to use handlebars trusted url syntax {{{verify_link}}}
- fix verification enqueueing to include channel in template rendering
- use locale enum for validation and display instead of string array separately maintained
- support text only templates for signal and discord
- fix missing verify_link and verify_page in migration and signup verification templates with unit tests
- consolidated body and subject notice methods into a single rendered function
2026-10-14 10:24:25 +00:00

1.3 KiB

Notification templates

Channel-neutral templates used by every comms channel (email, Telegram, Discord, Signal). The same body.txt renders the message content for each channel; the optional body.html is used only for the email HTML part (via queue metadata).

Layout expected by tranquil-pds when comms.templates_dir is set:

{templates_dir}/{locale}/{id}.subject.txt
{templates_dir}/{locale}/{id}.body.txt
{templates_dir}/{locale}/{id}.body.html

Templates use Handlebars syntax ({{hostname}}, {{handle}}, {{code}}, and so on). Built-in notification strings use the same syntax. Plain-text templates support the full expression set ({{#if}}, {{else if}}, {{#unless}}, {{#with}}); HTML templates HTML-escape interpolated values by default, while subjects and plain-text bodies do not.

Required ids: welcome, password_reset, email_update, short_token, account_deletion, plc_operation, two_factor_code, passkey_recovery, signup_verification, legacy_login, migration_verification, channel_verification, channel_verified.

The en/ directory is a complete example set you can copy and brand. It shows conditionals in both plain text and HTML, e.g. email_update only renders the one-click verify link when verify_link is provided.