feat: allow discussion notification customization #3072
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds customizations for discussion notification emails:
external_url
: the URL the notification email points tomodel_name
: the model name used in the notification emailAlso allows notifications for
Topic
.The expected payload is in
Discussion.extras
. It will be used for subsequent notifications of comments on discussion and discussion closing. A comment made on a discussion pointing to an external site will always point to this external site, even if made on another frontend.Both parameters are protected through an access list, to avoid ill-intentioned people injecting links or other arbitrary text in the notification emails:
DISCUSSION_ALLOWED_EXTERNAL_DOMAINS
(accepts wildcards)DISCUSSION_ALTERNATE_MODEL_NAMES
Both parameters can be omitted, the default behavior will apply. For
Topic
, since there's no detail page on data.gouv.fr (yet), no notification will be sent ifexternal_url
is not supplied.NB1: there's a grammatical error in the English notification text
Your %(type)s have a new discussion
, not fixed here because it would involve updating the translations.NB2: the translation of
model_name
is not handled. This is not a problem for ecologie.data.gouv.fr and might not be easy to do (how to add a translation for something variable? or include translations in payload?).Cf ecolabdata/ecospheres#263 for requirements and more details.