fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix template.
[wolnelektury.git]
/
src
/
push
/
utils.py
diff --git
a/src/push/utils.py
b/src/push/utils.py
index
98f0359
..
eb11984
100644
(file)
--- a/
src/push/utils.py
+++ b/
src/push/utils.py
@@
-1,4
+1,3
@@
-# -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
@@
-6,15
+5,24
@@
import firebase_admin
from firebase_admin import credentials, messaging
from django.conf import settings
from firebase_admin import credentials, messaging
from django.conf import settings
-cred = credentials.Certificate(settings.FCM_PRIVATE_KEY_PATH)
-firebase_admin.initialize_app(cred)
+
+cred = None
+if hasattr(settings, 'FCM_PRIVATE_KEY_PATH'):
+ cred = credentials.Certificate(settings.FCM_PRIVATE_KEY_PATH)
+ firebase_admin.initialize_app(cred)
TOPIC = 'wolnelektury'
def send_fcm_push(title, body, image_url=None):
TOPIC = 'wolnelektury'
def send_fcm_push(title, body, image_url=None):
+ if cred is None:
+ return
# See documentation on defining a message payload.
data = {}
# See documentation on defining a message payload.
data = {}
+ # data = {
+ # 'title': title,
+ # 'body': body,
+ # }
if image_url:
data['imageUrl'] = image_url
message = messaging.Message(
if image_url:
data['imageUrl'] = image_url
message = messaging.Message(