forked from Netflix/dispatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow customizing notification templates per project (Netflix#3369)
* project specific templates
- Loading branch information
Showing
3 changed files
with
73 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Messaging | ||
|
||
Dispatch supports sending email notifications to participants of, for example, an incident. | ||
|
||
## Notification templates | ||
|
||
Templates for emails are [part](https://github.com/Netflix/dispatch/tree/master/src/dispatch/messaging/email/templates) of Dispatch | ||
and are [Jinja](https://jinja.palletsprojects.com/) templates that during runtime are compiled into [MJML](https://mjml.io/) format. | ||
|
||
There is a way to customize these templates. To do this, if you run Dispatch with [Docker Compose](https://github.com/Netflix/dispatch-docker/), | ||
mount a volume with a customized templates dir as part of the docker compose: | ||
|
||
``` | ||
web: | ||
image: dispatch-local | ||
... | ||
volumes: | ||
- "../dispatch-templates/messaging-email-templates:/usr/local/lib/python3.11/site-packages/dispatch/messaging/email/templates" | ||
``` | ||
|
||
Such approach allows you to customize the common template for *all projects*. | ||
|
||
You can also "patch" the templates *per project*. Create a folder per project (identified by project id): | ||
|
||
``` | ||
dispatch/messaging/email/templates/project_id/<project_id>/base.mjml | ||
``` | ||
|
||
This will be used at the first place if exists, | ||
otherwise the resolution process will gracefully fall back to the default template: | ||
|
||
``` | ||
dispatch/messaging/email/templates/base.mjml | ||
``` | ||
|
||
|
||
## Markdown in the notifications | ||
|
||
:::warning | ||
Watch out for security implications related to unescaped HTML that may propagate through the system. | ||
::: | ||
|
||
By default, notification text is just a plain text with special characters and HTML escaped. | ||
|
||
It is possible, however, to enable Markdown syntax with a server setting: | ||
|
||
``` | ||
DISPATCH_MARKDOWN_IN_INCIDENT_DESC=True | ||
DISPATCH_ESCAPE_HTML=False | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters