summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-08-03 17:30:58 -0700
committerAndrew Morgan <andrew@amorgan.xyz>2020-08-03 17:30:58 -0700
commitaed7f97a5c2394935195b0b46e5d73fa7330041d (patch)
treee4b8ec4a3afb581cd29c8350fb0f4b5b3573b1fb
parentMerge commit '457096e6d' into anoa/dinsic_release_1_18_x (diff)
parentCorrectly pass app_name to all email templates. (#7829) (diff)
downloadsynapse-aed7f97a5c2394935195b0b46e5d73fa7330041d.tar.xz
Merge commit 'f886a6991' into anoa/dinsic_release_1_18_x
* commit 'f886a6991':
  Correctly pass app_name to all email templates. (#7829)
-rw-r--r--changelog.d/7829.bugfix1
-rw-r--r--synapse/push/mailer.py10
2 files changed, 9 insertions, 2 deletions
diff --git a/changelog.d/7829.bugfix b/changelog.d/7829.bugfix
new file mode 100644

index 0000000000..dcbf385de6 --- /dev/null +++ b/changelog.d/7829.bugfix
@@ -0,0 +1 @@ +Fix bug where we did not always pass in `app_name` or `server_name` to email templates, including e.g. for registration emails. diff --git a/synapse/push/mailer.py b/synapse/push/mailer.py
index dda560b2c2..a10dba0af6 100644 --- a/synapse/push/mailer.py +++ b/synapse/push/mailer.py
@@ -269,7 +269,6 @@ class Mailer(object): user_id, app_id, email_address ), "summary_text": summary_text, - "app_name": self.app_name, "rooms": rooms, "reason": reason, } @@ -278,7 +277,7 @@ class Mailer(object): email_address, "[%s] %s" % (self.app_name, summary_text), template_vars ) - async def send_email(self, email_address, subject, template_vars): + async def send_email(self, email_address, subject, extra_template_vars): """Send an email with the given information and template text""" try: from_string = self.hs.config.email_notif_from % {"app": self.app_name} @@ -291,6 +290,13 @@ class Mailer(object): if raw_to == "": raise RuntimeError("Invalid 'to' address") + template_vars = { + "app_name": self.app_name, + "server_name": self.hs.config.server.server_name, + } + + template_vars.update(extra_template_vars) + html_text = self.template_html.render(**template_vars) html_part = MIMEText(html_text, "html", "utf8")