X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/950cb3a2a7d1b478287d0255f9f9419f8cc18c43..HEAD:/src/push/utils.py diff --git a/src/push/utils.py b/src/push/utils.py index cd67f9cc1..44acb0662 100644 --- a/src/push/utils.py +++ b/src/push/utils.py @@ -1,18 +1,22 @@ -# -*- 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 Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # 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 = {