mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
Allow overwriting of APNS as iOS will send it on each startup
(imported from commit 4a22f9f37d550b6c2e06f543434466453e196458)
This commit is contained in:
@@ -2705,11 +2705,12 @@ def add_apns_device_token(request, user_profile, token=REQ):
|
|||||||
if token == '' or len(token) > 255:
|
if token == '' or len(token) > 255:
|
||||||
return json_error('Empty or invalid length APNS token')
|
return json_error('Empty or invalid length APNS token')
|
||||||
|
|
||||||
try:
|
# The iOS app receives the token on each startup, so overwrite with our
|
||||||
apns_token = AppleDeviceToken(user=user_profile, token=token)
|
# latest value
|
||||||
apns_token.save()
|
token, created = AppleDeviceToken.objects.get_or_create(user=user_profile, token=token)
|
||||||
except IntegrityError:
|
if not created:
|
||||||
return json_error("APNS token already exists")
|
token.last_updated = now()
|
||||||
|
token.save(update_fields=['last_updated'])
|
||||||
|
|
||||||
return json_success()
|
return json_success()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user