diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index d6892d7b99..b33e09c93d 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -3332,8 +3332,8 @@ def get_userids_for_missed_messages(realm, sender_id, message_type, active_user_ for user_id in active_user_ids: flags = user_flags.get(user_id, []) # type: Iterable[str] mentioned = 'mentioned' in flags - received_pm = is_pm and user_id != sender_id - if mentioned or received_pm: + private_message = is_pm and user_id != sender_id + if mentioned or private_message: user_ids.add(user_id) if not user_ids: diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py index 9c7adfdf3f..f487c90b27 100644 --- a/zerver/lib/push_notifications.py +++ b/zerver/lib/push_notifications.py @@ -329,9 +329,9 @@ def get_alert_from_message(message): Determine what alert string to display based on the missed messages. """ sender_str = message.sender.full_name - if message.recipient.type == Recipient.HUDDLE and message.triggers['received_pm']: + if message.recipient.type == Recipient.HUDDLE and message.triggers['private_message']: return "New private group message from %s" % (sender_str,) - elif message.recipient.type == Recipient.PERSONAL and message.triggers['received_pm']: + elif message.recipient.type == Recipient.PERSONAL and message.triggers['private_message']: return "New private message from %s" % (sender_str,) elif message.recipient.type == Recipient.STREAM and message.triggers['mentioned']: return "New mention from %s" % (sender_str,) @@ -401,7 +401,7 @@ def handle_push_notification(user_profile_id, missed_message): message = umessage.message triggers = missed_message.get('triggers') message.triggers = { - 'received_pm': triggers.get('received_pm', False), + 'private_message': triggers.get('private_message', False), 'mentioned': triggers.get('mentioned', False), 'stream_push_notify': triggers.get('stream_push_notify', False), } diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index 8cc3277323..5a964221d9 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -340,7 +340,7 @@ class HandlePushNotificationTest(PushNotificationTest): missed_message = { 'message_id': message.id, 'triggers': { - 'received_pm': True, + 'private_message': True, 'mentioned': False, 'stream_push_notify': False, }, @@ -399,7 +399,7 @@ class HandlePushNotificationTest(PushNotificationTest): 'user_profile_id': self.user_profile.id, 'message_id': message.id, 'triggers': { - 'received_pm': True, + 'private_message': True, 'mentioned': False, 'stream_push_notify': False, }, @@ -450,7 +450,7 @@ class HandlePushNotificationTest(PushNotificationTest): missed_message = { 'message_id': message.id, 'triggers': { - 'received_pm': True, + 'private_message': True, 'mentioned': False, 'stream_push_notify': False, }, @@ -469,7 +469,7 @@ class HandlePushNotificationTest(PushNotificationTest): missed_message = { 'message_id': message.id, 'triggers': { - 'received_pm': True, + 'private_message': True, 'mentioned': False, 'stream_push_notify': False, }, @@ -512,7 +512,7 @@ class HandlePushNotificationTest(PushNotificationTest): missed_message = { 'message_id': message.id, 'triggers': { - 'received_pm': True, + 'private_message': True, 'mentioned': False, 'stream_push_notify': False, }, @@ -586,7 +586,7 @@ class TestGetAlertFromMessage(PushNotificationTest): # type: () -> None message = self.get_message(Recipient.HUDDLE) message.triggers = { - 'received_pm': True, + 'private_message': True, 'mentioned': False, 'stream_push_notify': False, } @@ -597,7 +597,7 @@ class TestGetAlertFromMessage(PushNotificationTest): # type: () -> None message = self.get_message(Recipient.PERSONAL) message.triggers = { - 'received_pm': True, + 'private_message': True, 'mentioned': False, 'stream_push_notify': False, } @@ -608,7 +608,7 @@ class TestGetAlertFromMessage(PushNotificationTest): # type: () -> None message = self.get_message(Recipient.STREAM) message.triggers = { - 'received_pm': False, + 'private_message': False, 'mentioned': True, 'stream_push_notify': False, } @@ -619,7 +619,7 @@ class TestGetAlertFromMessage(PushNotificationTest): # type: () -> None message = self.get_message(Recipient.STREAM) message.triggers = { - 'received_pm': False, + 'private_message': False, 'mentioned': False, 'stream_push_notify': True, } @@ -631,7 +631,7 @@ class TestGetAlertFromMessage(PushNotificationTest): # type: () -> None message = self.get_message(0) message.triggers = { - 'received_pm': False, + 'private_message': False, 'mentioned': False, 'stream_push_notify': False, } @@ -646,7 +646,7 @@ class TestGetAPNsPayload(PushNotificationTest): # type: () -> None message = self.get_message(Recipient.HUDDLE) message.triggers = { - 'received_pm': True, + 'private_message': True, 'mentioned': False, 'stream_push_notify': False, } @@ -670,7 +670,7 @@ class TestGetGCMPayload(PushNotificationTest): message.content = 'a' * 210 message.save() message.triggers = { - 'received_pm': False, + 'private_message': False, 'mentioned': True, 'stream_push_notify': False, } @@ -698,7 +698,7 @@ class TestGetGCMPayload(PushNotificationTest): # type: () -> None message = self.get_message(Recipient.PERSONAL, 1) message.triggers = { - 'received_pm': True, + 'private_message': True, 'mentioned': False, 'stream_push_notify': False, } @@ -723,7 +723,7 @@ class TestGetGCMPayload(PushNotificationTest): # type: () -> None message = self.get_message(Recipient.STREAM, 1) message.triggers = { - 'received_pm': False, + 'private_message': False, 'mentioned': False, 'stream_push_notify': True, } diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 62586bb00f..4f9c829140 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -688,18 +688,18 @@ def process_message_event(event_template, users): # If the recipient was offline and the message was a single or group PM to them # or they were @-notified potentially notify more immediately - received_pm = message_type == "private" and user_profile_id != sender_id + private_message = message_type == "private" and user_profile_id != sender_id mentioned = 'mentioned' in flags stream_push_notify = user_data.get('stream_push_notify', False) - if (received_pm or mentioned or stream_push_notify): + if (private_message or mentioned or stream_push_notify): idle = receiver_is_off_zulip(user_profile_id) or (user_profile_id in missed_message_userids) always_push_notify = user_data.get('always_push_notify', False) if (idle or always_push_notify): notice = build_offline_notification(user_profile_id, message_id) notice['triggers'] = { - 'received_pm': received_pm, + 'private_message': private_message, 'mentioned': mentioned, 'stream_push_notify': stream_push_notify, }