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