Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Correctly pass app_name to all email templates. #7829

Merged
merged 3 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/7829.bugfix
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this "always" been this way or was it broken at some point? (Do we need to add a "broken since v..."?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this has always been broken for these emails, as they were added later at different times

9 changes: 8 additions & 1 deletion synapse/push/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async def _fetch_room_state(room_id):
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}
Expand All @@ -291,6 +291,13 @@ async def send_email(self, email_address, subject, template_vars):
if raw_to == "":
raise RuntimeError("Invalid 'to' address")

template_vars = {
"app_name": self.app_name,
"server_name": self.hs.config.server.server_name,
}
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved

template_vars.update(extra_template_vars)

html_text = self.template_html.render(**template_vars)
html_part = MIMEText(html_text, "html", "utf8")

Expand Down