mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	push_notifications: Provide message timestamp in both APNS and GCM notifications.
This commit is contained in:
		@@ -803,6 +803,7 @@ def get_message_payload(
 | 
				
			|||||||
    # `sender_id` is preferred, but some existing versions use `sender_email`.
 | 
					    # `sender_id` is preferred, but some existing versions use `sender_email`.
 | 
				
			||||||
    data["sender_id"] = message.sender.id
 | 
					    data["sender_id"] = message.sender.id
 | 
				
			||||||
    data["sender_email"] = message.sender.email
 | 
					    data["sender_email"] = message.sender.email
 | 
				
			||||||
 | 
					    data["time"] = message.date_sent.timestamp()
 | 
				
			||||||
    if mentioned_user_group_id is not None:
 | 
					    if mentioned_user_group_id is not None:
 | 
				
			||||||
        assert mentioned_user_group_name is not None
 | 
					        assert mentioned_user_group_name is not None
 | 
				
			||||||
        data["mentioned_user_group_id"] = mentioned_user_group_id
 | 
					        data["mentioned_user_group_id"] = mentioned_user_group_id
 | 
				
			||||||
@@ -941,7 +942,6 @@ def get_message_payload_gcm(
 | 
				
			|||||||
        data.update(
 | 
					        data.update(
 | 
				
			||||||
            event="message",
 | 
					            event="message",
 | 
				
			||||||
            zulip_message_id=message.id,  # message_id is reserved for CCS
 | 
					            zulip_message_id=message.id,  # message_id is reserved for CCS
 | 
				
			||||||
            time=message.date_sent.timestamp(),
 | 
					 | 
				
			||||||
            content=content,
 | 
					            content=content,
 | 
				
			||||||
            content_truncated=truncated,
 | 
					            content_truncated=truncated,
 | 
				
			||||||
            sender_full_name=message.sender.full_name,
 | 
					            sender_full_name=message.sender.full_name,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1981,6 +1981,7 @@ class TestGetAPNsPayload(PushNotificationTest):
 | 
				
			|||||||
                    "realm_id": self.sender.realm.id,
 | 
					                    "realm_id": self.sender.realm.id,
 | 
				
			||||||
                    "realm_uri": self.sender.realm.uri,
 | 
					                    "realm_uri": self.sender.realm.uri,
 | 
				
			||||||
                    "user_id": user_profile.id,
 | 
					                    "user_id": user_profile.id,
 | 
				
			||||||
 | 
					                    "time": message.date_sent.timestamp(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -2023,6 +2024,7 @@ class TestGetAPNsPayload(PushNotificationTest):
 | 
				
			|||||||
                    "realm_id": self.sender.realm.id,
 | 
					                    "realm_id": self.sender.realm.id,
 | 
				
			||||||
                    "realm_uri": self.sender.realm.uri,
 | 
					                    "realm_uri": self.sender.realm.uri,
 | 
				
			||||||
                    "user_id": user_profile.id,
 | 
					                    "user_id": user_profile.id,
 | 
				
			||||||
 | 
					                    "time": message.date_sent.timestamp(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -2054,6 +2056,7 @@ class TestGetAPNsPayload(PushNotificationTest):
 | 
				
			|||||||
                    "realm_id": self.sender.realm.id,
 | 
					                    "realm_id": self.sender.realm.id,
 | 
				
			||||||
                    "realm_uri": self.sender.realm.uri,
 | 
					                    "realm_uri": self.sender.realm.uri,
 | 
				
			||||||
                    "user_id": self.sender.id,
 | 
					                    "user_id": self.sender.id,
 | 
				
			||||||
 | 
					                    "time": message.date_sent.timestamp(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -2091,6 +2094,7 @@ class TestGetAPNsPayload(PushNotificationTest):
 | 
				
			|||||||
                    "realm_id": self.sender.realm.id,
 | 
					                    "realm_id": self.sender.realm.id,
 | 
				
			||||||
                    "realm_uri": self.sender.realm.uri,
 | 
					                    "realm_uri": self.sender.realm.uri,
 | 
				
			||||||
                    "user_id": user_profile.id,
 | 
					                    "user_id": user_profile.id,
 | 
				
			||||||
 | 
					                    "time": message.date_sent.timestamp(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -2129,6 +2133,7 @@ class TestGetAPNsPayload(PushNotificationTest):
 | 
				
			|||||||
                    "user_id": user_profile.id,
 | 
					                    "user_id": user_profile.id,
 | 
				
			||||||
                    "mentioned_user_group_id": user_group.id,
 | 
					                    "mentioned_user_group_id": user_group.id,
 | 
				
			||||||
                    "mentioned_user_group_name": user_group.name,
 | 
					                    "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_id": self.sender.realm.id,
 | 
				
			||||||
                    "realm_uri": self.sender.realm.uri,
 | 
					                    "realm_uri": self.sender.realm.uri,
 | 
				
			||||||
                    "user_id": user_profile.id,
 | 
					                    "user_id": user_profile.id,
 | 
				
			||||||
 | 
					                    "time": message.date_sent.timestamp(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -2224,6 +2230,7 @@ class TestGetAPNsPayload(PushNotificationTest):
 | 
				
			|||||||
                    "realm_id": self.sender.realm.id,
 | 
					                    "realm_id": self.sender.realm.id,
 | 
				
			||||||
                    "realm_uri": self.sender.realm.uri,
 | 
					                    "realm_uri": self.sender.realm.uri,
 | 
				
			||||||
                    "user_id": user_profile.id,
 | 
					                    "user_id": user_profile.id,
 | 
				
			||||||
 | 
					                    "time": message.date_sent.timestamp(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user