Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

push_notifications: Provide message timestamp in both APNS and GCM notifications.

Alex Vandiverfd6091ad17b5
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py
index 180311ed60c..d7798024be7 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 fbec6415f24..43c84f0d1f1 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(),
},
},
}