opendatateam / udata

Customizable and skinnable social platform dedicated to open data.
http://udata.readthedocs.org
GNU Affero General Public License v3.0
238 stars 87 forks source link

feat: allow discussion notification customization #3072

Open abulte opened 1 month ago

abulte commented 1 month ago

Adds customizations for discussion notification emails:

Also 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.

{
  "notification": {
    "model_name": "bouquet",
    "external_url": "https://ecologie.data.gouv.fr/bouquets/xxx"
  }
}

Both parameters are protected through an access list, to avoid ill-intentioned people injecting links or other arbitrary text in the notification emails:

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 if external_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 https://github.com/ecolabdata/ecospheres/issues/263 for requirements and more details.