context_processors: use a common context for emails.

Fixes #1611.
This commit is contained in:
paxapy
2016-11-08 12:07:47 +03:00
committed by Tim Abbott
parent 8c7ed80281
commit ff1e97603d
5 changed files with 45 additions and 40 deletions

View File

@@ -235,6 +235,7 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile, missed_messages, m
`missed_messages` is a list of Message objects to remind about they should
all have the same recipient and subject
"""
from zerver.context_processors import common_context
# Disabled missedmessage emails internally
if not user_profile.enable_offline_email_notifications:
return
@@ -247,19 +248,16 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile, missed_messages, m
)
unsubscribe_link = one_click_unsubscribe_link(user_profile, "missed_messages")
template_payload = {
template_payload = common_context(user_profile)
template_payload.update({
'name': user_profile.full_name,
'messages': build_message_list(user_profile, missed_messages),
'message_count': message_count,
'reply_warning': False,
'external_host': settings.EXTERNAL_HOST,
'external_uri_scheme': settings.EXTERNAL_URI_SCHEME,
'server_uri': settings.SERVER_URI,
'realm_uri': user_profile.realm.uri,
'mention': missed_messages[0].recipient.type == Recipient.STREAM,
'reply_to_zulip': True,
'unsubscribe_link': unsubscribe_link,
}
})
headers = {}
from zerver.lib.email_mirror import create_missed_message_address
@@ -469,6 +467,7 @@ def send_local_email_template_with_delay(recipients, template_prefix,
def enqueue_welcome_emails(email, name):
# type: (text_type, text_type) -> None
from zerver.context_processors import common_context
if settings.WELCOME_EMAIL_SENDER is not None:
sender = settings.WELCOME_EMAIL_SENDER # type: Dict[str, text_type]
else:
@@ -476,13 +475,11 @@ def enqueue_welcome_emails(email, name):
user_profile = get_user_profile_by_email(email)
unsubscribe_link = one_click_unsubscribe_link(user_profile, "welcome")
template_payload = {'verbose_support_offers': settings.VERBOSE_SUPPORT_OFFERS,
'external_host': settings.EXTERNAL_HOST,
'external_uri_scheme': settings.EXTERNAL_URI_SCHEME,
'server_uri': settings.SERVER_URI,
'realm_uri': user_profile.realm.uri,
'unsubscribe_link': unsubscribe_link}
template_payload = common_context(user_profile)
template_payload.update({
'verbose_support_offers': settings.VERBOSE_SUPPORT_OFFERS,
'unsubscribe_link': unsubscribe_link
})
# Send day 1 email
send_local_email_template_with_delay([{'email': email, 'name': name}],