settings: If message content disabled, flush all missed emails informations.

If user has disabled message content in missed email notifications,
we shouldn't send any informations about missed messages i.e. sender,
stream, message text, etc. to email servers.
We are already hiding this informations in email templates, but we
shoudln't expose any information about message content if user
has disabled this setting.
This commit is contained in:
YJDave
2018-03-08 12:57:29 +05:30
committed by Tim Abbott
parent dfbe1e4914
commit ee87c146ff

View File

@@ -299,7 +299,6 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile,
context = common_context(user_profile) context = common_context(user_profile)
context.update({ context.update({
'name': user_profile.full_name, 'name': user_profile.full_name,
'messages': build_message_list(user_profile, missed_messages),
'message_count': message_count, 'message_count': message_count,
'mention': missed_messages[0].is_stream_message(), 'mention': missed_messages[0].is_stream_message(),
'unsubscribe_link': unsubscribe_link, 'unsubscribe_link': unsubscribe_link,
@@ -321,12 +320,6 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile,
'reply_to_zulip': False, 'reply_to_zulip': False,
}) })
# If there is no content in message, it's not clear what user would be replying to.
if not user_profile.message_content_in_email_notifications:
context.update({
'reply_to_zulip': False,
})
from zerver.lib.email_mirror import create_missed_message_address from zerver.lib.email_mirror import create_missed_message_address
reply_to_address = create_missed_message_address(user_profile, missed_messages[0]) reply_to_address = create_missed_message_address(user_profile, missed_messages[0])
if reply_to_address == FromAddress.NOREPLY: if reply_to_address == FromAddress.NOREPLY:
@@ -365,7 +358,18 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile,
flags=UserMessage.flags.mentioned).exists())) flags=UserMessage.flags.mentioned).exists()))
context.update({'at_mention': True}) context.update({'at_mention': True})
# If message content is disabled, then flush all information we pass to email.
if not user_profile.message_content_in_email_notifications:
context.update({ context.update({
'reply_to_zulip': False,
'messages': [],
'sender_str': "",
'realm_str': user_profile.realm.name,
'huddle_display_name': "",
})
else:
context.update({
'messages': build_message_list(user_profile, missed_messages),
'sender_str': ", ".join(sender.full_name for sender in senders), 'sender_str': ", ".join(sender.full_name for sender in senders),
'realm_str': user_profile.realm.name, 'realm_str': user_profile.realm.name,
}) })