0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-05-20 04:23:44 +02:00

Correctly pass app_name to all email templates. (#7829)

We didn't do this for e.g. registration emails.
This commit is contained in:
Erik Johnston 2020-07-14 10:00:53 +01:00 committed by GitHub
parent 457096e6df
commit f886a69916
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

1
changelog.d/7829.bugfix Normal file
View file

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

View file

@ -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")