From bad0ebfd2747e44e647b743e866a5cb42994d16e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Sat, 15 Dec 2018 23:13:59 +0100 Subject: [PATCH] Don't panic about lack of Firebase key. --- src/push/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/push/utils.py b/src/push/utils.py index cd67f9cc1..684531588 100644 --- a/src/push/utils.py +++ b/src/push/utils.py @@ -6,13 +6,18 @@ import firebase_admin 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): + if cred is None: + return # See documentation on defining a message payload. data = {} # data = { -- 2.20.1