mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 20:02:15 +00:00
push_notifications: Fix interface for handle_remove_push_notification.
This really should just accept a message ID.
This commit is contained in:
@@ -548,7 +548,7 @@ def get_gcm_payload(user_profile: UserProfile, message: Message) -> Dict[str, An
|
||||
})
|
||||
return data
|
||||
|
||||
def handle_remove_push_notification(user_profile_id: int, remove_message: Dict[str, Any]) -> None:
|
||||
def handle_remove_push_notification(user_profile_id: int, message_id: int) -> None:
|
||||
"""This should be called when a message that had previously had a
|
||||
mobile push executed is read. This triggers a mobile push notifica
|
||||
mobile app when the message is read on the server, to remove the
|
||||
@@ -556,11 +556,11 @@ def handle_remove_push_notification(user_profile_id: int, remove_message: Dict[s
|
||||
|
||||
"""
|
||||
user_profile = get_user_profile_by_id(user_profile_id)
|
||||
message = access_message(user_profile, remove_message['message_id'])[0]
|
||||
message = access_message(user_profile, message_id)[0]
|
||||
gcm_payload = get_common_payload(message)
|
||||
gcm_payload.update({
|
||||
'event': 'remove',
|
||||
'zulip_message_id': remove_message['message_id'], # message_id is reserved for CCS
|
||||
'zulip_message_id': message_id, # message_id is reserved for CCS
|
||||
})
|
||||
|
||||
if uses_notification_bouncer():
|
||||
|
||||
@@ -544,15 +544,12 @@ class HandlePushNotificationTest(PushNotificationTest):
|
||||
message=message
|
||||
)
|
||||
|
||||
remove_message = {
|
||||
'message_id': message.id,
|
||||
}
|
||||
with self.settings(PUSH_NOTIFICATION_BOUNCER_URL=True), \
|
||||
mock.patch('zerver.lib.push_notifications'
|
||||
'.send_notifications_to_bouncer') as mock_send_android, \
|
||||
mock.patch('zerver.lib.push_notifications.get_common_payload',
|
||||
return_value={'gcm': True}):
|
||||
apn.handle_remove_push_notification(user_profile.id, remove_message)
|
||||
apn.handle_remove_push_notification(user_profile.id, message.id)
|
||||
mock_send_android.assert_called_with(user_profile.id, {},
|
||||
{'gcm': True,
|
||||
'event': 'remove',
|
||||
@@ -575,15 +572,11 @@ class HandlePushNotificationTest(PushNotificationTest):
|
||||
PushDeviceToken.objects.filter(user=self.user_profile,
|
||||
kind=PushDeviceToken.GCM))
|
||||
|
||||
remove_message = {
|
||||
'message_id': message.id,
|
||||
}
|
||||
|
||||
with mock.patch('zerver.lib.push_notifications'
|
||||
'.send_android_push_notification') as mock_send_android, \
|
||||
mock.patch('zerver.lib.push_notifications.get_common_payload',
|
||||
return_value={'gcm': True}):
|
||||
apn.handle_remove_push_notification(self.user_profile.id, remove_message)
|
||||
apn.handle_remove_push_notification(self.user_profile.id, message.id)
|
||||
mock_send_android.assert_called_with(android_devices,
|
||||
{'gcm': True,
|
||||
'event': 'remove',
|
||||
|
||||
Reference in New Issue
Block a user