Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
thalia
concrexit
Commits
5bde87dd
Verified
Commit
5bde87dd
authored
Oct 17, 2019
by
Sébastiaan Versteeg
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix removal of Firebase Admin SDK error
parent
64067ce2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
website/pushnotifications/models.py
website/pushnotifications/models.py
+12
-9
No files found.
website/pushnotifications/models.py
View file @
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
Device
.
objects
.
filter
(
registration_id
=
reg_id
).
delete
()
except
exceptions
.
InvalidArgumentError
:
failure_total
+=
1
Device
.
objects
.
filter
(
registration_id
=
reg_id
).
update
(
active
=
False
)
except
exceptions
.
FirebaseError
:
failure_total
+=
1
d
=
Device
.
objects
.
filter
(
registration_id
=
reg_id
)
if
e
.
code
==
'registration-token-not-registered'
:
d
.
delete
()
elif
(
e
.
code
==
'invalid-argument'
or
e
.
code
==
'invalid-recipient'
or
e
.
code
==
'invalid-registration-token'
):
d
.
update
(
active
=
False
)
self
.
sent
=
True
self
.
success
=
success_total
...
...
Luko van der Maas
@lukomaas
mentioned in commit
5b8bd1ce
·
Oct 19, 2019
mentioned in commit
5b8bd1ce
mentioned in commit 5b8bd1ce06b2754d424bc2f790b346c410c321f4
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment