From fd6091ad17b5e9e9e786418e3e8053332c67c0f9 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 22 Sep 2023 18:26:21 +0000 Subject: [PATCH] push_notifications: Provide message timestamp in both APNS and GCM notifications. --- zerver/lib/push_notifications.py | 2 +- zerver/tests/test_push_notifications.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py index 180311ed60..d7798024be 100644 --- a/zerver/lib/push_notifications.py +++ b/zerver/lib/push_notifications.py @@ -803,6 +803,7 @@ def get_message_payload( # `sender_id` is preferred, but some existing versions use `sender_email`. data["sender_id"] = message.sender.id data["sender_email"] = message.sender.email + data["time"] = message.date_sent.timestamp() if mentioned_user_group_id is not None: assert mentioned_user_group_name is not None data["mentioned_user_group_id"] = mentioned_user_group_id @@ -941,7 +942,6 @@ def get_message_payload_gcm( data.update( event="message", zulip_message_id=message.id, # message_id is reserved for CCS - time=message.date_sent.timestamp(), content=content, content_truncated=truncated, sender_full_name=message.sender.full_name, diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index fbec6415f2..43c84f0d1f 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -1981,6 +1981,7 @@ class TestGetAPNsPayload(PushNotificationTest): "realm_id": self.sender.realm.id, "realm_uri": self.sender.realm.uri, "user_id": user_profile.id, + "time": message.date_sent.timestamp(), }, }, } @@ -2023,6 +2024,7 @@ class TestGetAPNsPayload(PushNotificationTest): "realm_id": self.sender.realm.id, "realm_uri": self.sender.realm.uri, "user_id": user_profile.id, + "time": message.date_sent.timestamp(), }, }, } @@ -2054,6 +2056,7 @@ class TestGetAPNsPayload(PushNotificationTest): "realm_id": self.sender.realm.id, "realm_uri": self.sender.realm.uri, "user_id": self.sender.id, + "time": message.date_sent.timestamp(), }, }, } @@ -2091,6 +2094,7 @@ class TestGetAPNsPayload(PushNotificationTest): "realm_id": self.sender.realm.id, "realm_uri": self.sender.realm.uri, "user_id": user_profile.id, + "time": message.date_sent.timestamp(), }, }, } @@ -2129,6 +2133,7 @@ class TestGetAPNsPayload(PushNotificationTest): "user_id": user_profile.id, "mentioned_user_group_id": user_group.id, "mentioned_user_group_name": user_group.name, + "time": message.date_sent.timestamp(), } }, } @@ -2164,6 +2169,7 @@ class TestGetAPNsPayload(PushNotificationTest): "realm_id": self.sender.realm.id, "realm_uri": self.sender.realm.uri, "user_id": user_profile.id, + "time": message.date_sent.timestamp(), }, }, } @@ -2224,6 +2230,7 @@ class TestGetAPNsPayload(PushNotificationTest): "realm_id": self.sender.realm.id, "realm_uri": self.sender.realm.uri, "user_id": user_profile.id, + "time": message.date_sent.timestamp(), }, }, }