mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
emails: Fix subject -> email_subject in send_email.py.
This commit is contained in:
@@ -30,7 +30,6 @@ FILES_WITH_LEGACY_SUBJECT = {
|
||||
# probably always be exempt:
|
||||
'zerver/lib/email_mirror.py',
|
||||
'zerver/lib/feedback.py',
|
||||
'zerver/lib/send_email.py',
|
||||
'zerver/tests/test_new_users.py',
|
||||
|
||||
# These are tied more to our API than our DB model.
|
||||
|
||||
@@ -57,7 +57,7 @@ def build_email(template_prefix: str, to_user_ids: Optional[List[int]]=None,
|
||||
})
|
||||
|
||||
def render_templates() -> Tuple[str, str, str]:
|
||||
subject = loader.render_to_string(template_prefix + '.subject.txt',
|
||||
email_subject = loader.render_to_string(template_prefix + '.subject.txt',
|
||||
context=context,
|
||||
using='Jinja2_plaintext').strip().replace('\n', '')
|
||||
message = loader.render_to_string(template_prefix + '.txt',
|
||||
@@ -70,16 +70,16 @@ def build_email(template_prefix: str, to_user_ids: Optional[List[int]]=None,
|
||||
template = os.path.basename(template_prefix)
|
||||
compiled_template_prefix = os.path.join(emails_dir, "compiled", template)
|
||||
html_message = loader.render_to_string(compiled_template_prefix + '.html', context)
|
||||
return (html_message, message, subject)
|
||||
return (html_message, message, email_subject)
|
||||
|
||||
if not language and to_user_ids is not None:
|
||||
language = to_users[0].default_language
|
||||
if language:
|
||||
with override_language(language):
|
||||
# Make sure that we render the email using the target's native language
|
||||
(html_message, message, subject) = render_templates()
|
||||
(html_message, message, email_subject) = render_templates()
|
||||
else:
|
||||
(html_message, message, subject) = render_templates()
|
||||
(html_message, message, email_subject) = render_templates()
|
||||
logger.warning("Missing language for email template '{}'".format(template_prefix))
|
||||
|
||||
if from_name is None:
|
||||
@@ -96,7 +96,7 @@ def build_email(template_prefix: str, to_user_ids: Optional[List[int]]=None,
|
||||
elif from_address == FromAddress.NOREPLY:
|
||||
reply_to = [FromAddress.NOREPLY]
|
||||
|
||||
mail = EmailMultiAlternatives(subject, message, from_email, to_emails, reply_to=reply_to)
|
||||
mail = EmailMultiAlternatives(email_subject, message, from_email, to_emails, reply_to=reply_to)
|
||||
if html_message is not None:
|
||||
mail.attach_alternative(html_message, 'text/html')
|
||||
return mail
|
||||
|
||||
Reference in New Issue
Block a user