From ee87c146ffbcf045644d3a7f36ccccd361d5d48d Mon Sep 17 00:00:00 2001 From: YJDave Date: Thu, 8 Mar 2018 12:57:29 +0530 Subject: [PATCH] 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. --- zerver/lib/notifications.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/zerver/lib/notifications.py b/zerver/lib/notifications.py index 1e50f59611..a829a3d5cb 100644 --- a/zerver/lib/notifications.py +++ b/zerver/lib/notifications.py @@ -299,7 +299,6 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile, context = common_context(user_profile) context.update({ 'name': user_profile.full_name, - 'messages': build_message_list(user_profile, missed_messages), 'message_count': message_count, 'mention': missed_messages[0].is_stream_message(), 'unsubscribe_link': unsubscribe_link, @@ -321,12 +320,6 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile, '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 reply_to_address = create_missed_message_address(user_profile, missed_messages[0]) if reply_to_address == FromAddress.NOREPLY: @@ -365,10 +358,21 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile, flags=UserMessage.flags.mentioned).exists())) context.update({'at_mention': True}) - context.update({ - 'sender_str': ", ".join(sender.full_name for sender in senders), - 'realm_str': user_profile.realm.name, - }) + # If message content is disabled, then flush all information we pass to email. + if not user_profile.message_content_in_email_notifications: + 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), + 'realm_str': user_profile.realm.name, + }) from_name = "Zulip missed messages" # type: Text from_address = FromAddress.NOREPLY