Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
push_notifs: Order device args to send_notifications_to_bouncer by id.
Mateusz Mandera3bcfb9c005d5
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.pyindex da5f69d237c..3f3bc182213 100644--- a/zerver/lib/push_notifications.py+++ b/zerver/lib/push_notifications.py@@ -1190,10 +1190,10 @@ def handle_remove_push_notification(user_profile_id: int, message_ids: List[int]apns_payload = get_remove_payload_apns(user_profile, truncated_message_ids)android_devices = list(- PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.GCM)+ PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.GCM).order_by("id"))apple_devices = list(- PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.APNS)+ PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.APNS).order_by("id"))if uses_notification_bouncer():send_notifications_to_bouncer(@@ -1356,11 +1356,11 @@ def handle_push_notification(user_profile_id: int, missed_message: Dict[str, Anylogger.info("Sending push notifications to mobile clients for user %s", user_profile_id)android_devices = list(- PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.GCM)+ PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.GCM).order_by("id"))apple_devices = list(- PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.APNS)+ PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.APNS).order_by("id"))if uses_notification_bouncer():total_android_devices, total_apple_devices = send_notifications_to_bouncer(diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.pyindex d179c23e4a7..7269375dc46 100644--- a/zerver/tests/test_push_notifications.py+++ b/zerver/tests/test_push_notifications.py@@ -2393,8 +2393,16 @@ class HandlePushNotificationTest(PushNotificationTest):{"apns": True},{"gcm": True},{},- list(PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.GCM)),- list(PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.APNS)),+ list(+ PushDeviceToken.objects.filter(+ user=user_profile, kind=PushDeviceToken.GCM+ ).order_by("id")+ ),+ list(+ PushDeviceToken.objects.filter(+ user=user_profile, kind=PushDeviceToken.APNS+ ).order_by("id")+ ),)self.assertEqual(mock_logging_info.output,@@ -2508,8 +2516,16 @@ class HandlePushNotificationTest(PushNotificationTest):"zulip_message_id": message.id,},{"priority": "normal"},- list(PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.GCM)),- list(PushDeviceToken.objects.filter(user=user_profile, kind=PushDeviceToken.APNS)),+ list(+ PushDeviceToken.objects.filter(+ user=user_profile, kind=PushDeviceToken.GCM+ ).order_by("id")+ ),+ list(+ PushDeviceToken.objects.filter(+ user=user_profile, kind=PushDeviceToken.APNS+ ).order_by("id")+ ),)user_message = UserMessage.objects.get(user_profile=self.user_profile, message=message)self.assertEqual(user_message.flags.active_mobile_push_notification, False)