Commit 027b7ee2 authored by Luko van der Maas's avatar Luko van der Maas

Merge branch 'fix/firebase-error' into 'master'

Fix removal of Firebase Admin SDK error

Closes #940

See merge request !1381
parents 0774d789 5bde87dd
......@@ -5,7 +5,7 @@ from django.conf import settings
from django.db import models
from django.utils.translation import override
from django.utils.translation import ugettext_lazy as _
from firebase_admin import messaging
from firebase_admin import messaging, exceptions
from utils.translation import MultilingualField, ModelTranslateMeta
......@@ -174,15 +174,18 @@ class Message(models.Model, metaclass=ModelTranslateMeta):
messaging.send(message, dry_run=kwargs.get(
'dry_run', False))
success_total += 1
except messaging.ApiCallError as e:
except messaging.UnregisteredError:
failure_total += 1
except exceptions.InvalidArgumentError:
failure_total += 1
except exceptions.FirebaseError:
failure_total += 1
d = Device.objects.filter(registration_id=reg_id)
if e.code == 'registration-token-not-registered':
elif (e.code == 'invalid-argument'
or e.code == 'invalid-recipient'
or e.code == 'invalid-registration-token'):
self.sent = True
self.success = success_total
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment