zilencer: Avoid creating duplicate remote push registrations.

Servers that had upgraded from a Zulip server version that did not yet
support the user_uuid field to one that did could end up with some
mobile devices having two push notifications registrations, one with a
user_id and the other with a user_uuid.

Fix this issue by sending both user_id and user_uuid, and clearing
This commit is contained in:
Mateusz Mandera
2023-04-10 00:23:59 +02:00
committed by Tim Abbott
parent d888bb3df2
commit ade2225f08
3 changed files with 48 additions and 14 deletions

View File

@@ -547,6 +547,9 @@ def add_push_device_token(
post_data = {
"server_uuid": settings.ZULIP_ORG_ID,
"user_uuid": str(user_profile.uuid),
# user_id is sent so that the bouncer can delete any pre-existing registrations
# for this user+device to avoid duplication upon adding the uuid registration.
"user_id": str(user_profile.id),
"token": token_str,
"token_kind": kind,
}