From 9d9f9dbf9c9b79e56e1d572e4568ad7f5d2f33aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=86=D0=B2=D0=B0=D0=BD=20=D0=9D=D1=94=D0=B4=D1=94=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=96=D1=86=D0=B5=D0=B2?= Date: Wed, 22 May 2024 13:52:07 +0300 Subject: [PATCH 1/5] refactor: [AXM-475] refactor firebase settings --- .../djangoapps/ace_common/settings/common.py | 44 +++++++++---------- .../ace_common/settings/production.py | 10 ++--- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/openedx/core/djangoapps/ace_common/settings/common.py b/openedx/core/djangoapps/ace_common/settings/common.py index 58341470ed8d..9bf96a3f6dfe 100644 --- a/openedx/core/djangoapps/ace_common/settings/common.py +++ b/openedx/core/djangoapps/ace_common/settings/common.py @@ -27,27 +27,25 @@ def plugin_settings(settings): # lint-amnesty, pylint: disable=missing-function settings.FEATURES['test_django_plugin'] = True settings.FCM_APP_NAME = 'fcm-edx-platform' - if getattr(settings, 'FIREBASE_SETUP_STATUS', None) is None: - settings.ACE_CHANNEL_DEFAULT_PUSH = 'push_notification' - - # Note: To local development with Firebase, you must set FIREBASE_CREDENTIALS. - settings.FCM_APP_NAME = 'fcm-edx-platform' - settings.FIREBASE_CREDENTIALS = None - - if firebase_app := setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME): - settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH) - settings.ACE_ENABLED_POLICIES.append(settings.ACE_CHANNEL_DEFAULT_PUSH) - - settings.PUSH_NOTIFICATIONS_SETTINGS = { - 'CONFIG': 'push_notifications.conf.AppConfig', - 'APPLICATIONS': { - settings.FCM_APP_NAME: { - 'PLATFORM': 'FCM', - 'FIREBASE_APP': firebase_app, - }, + settings.ACE_CHANNEL_DEFAULT_PUSH = 'push_notification' + # Note: To local development with Firebase, you must set FIREBASE_CREDENTIALS. + settings.FCM_APP_NAME = 'fcm-edx-platform' + settings.FIREBASE_CREDENTIALS = None + + if not getattr(settings, 'FIREBASE_APP', None) and settings.FIREBASE_CREDENTIALS: + settings.FIREBASE_APP = setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME) + + if getattr(settings, 'FIREBASE_APP', None): + settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH) + settings.ACE_ENABLED_POLICIES.append(settings.ACE_CHANNEL_DEFAULT_PUSH) + + settings.PUSH_NOTIFICATIONS_SETTINGS = { + 'CONFIG': 'push_notifications.conf.AppConfig', + 'APPLICATIONS': { + settings.FCM_APP_NAME: { + 'PLATFORM': 'FCM', + 'FIREBASE_APP': settings.FIREBASE_APP, }, - 'UPDATE_ON_DUPLICATE_REG_ID': True, - } - settings.FIREBASE_SETUP_STATUS = True - else: - settings.FIREBASE_SETUP_STATUS = False + }, + 'UPDATE_ON_DUPLICATE_REG_ID': True, + } diff --git a/openedx/core/djangoapps/ace_common/settings/production.py b/openedx/core/djangoapps/ace_common/settings/production.py index b7ac5b12db17..e0c3d11f4311 100644 --- a/openedx/core/djangoapps/ace_common/settings/production.py +++ b/openedx/core/djangoapps/ace_common/settings/production.py @@ -30,8 +30,9 @@ def plugin_settings(settings): settings.FCM_APP_NAME = settings.ENV_TOKENS.get('FCM_APP_NAME', 'fcm-edx-platform') settings.FIREBASE_CREDENTIALS = settings.ENV_TOKENS.get('FIREBASE_CREDENTIALS', {}) - if getattr(settings, 'FIREBASE_SETUP_STATUS', None) is None: - if firebase_app := setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME): + if not getattr(settings, 'FIREBASE_APP', None) and settings.FIREBASE_CREDENTIALS: + settings.FIREBASE_APP = setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME) + if settings.FIREBASE_APP: settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH) settings.ACE_ENABLED_POLICIES.append(settings.ACE_CHANNEL_DEFAULT_PUSH) @@ -40,11 +41,8 @@ def plugin_settings(settings): 'APPLICATIONS': { settings.FCM_APP_NAME: { 'PLATFORM': 'FCM', - 'FIREBASE_APP': firebase_app, + 'FIREBASE_APP': settings.FIREBASE_APP, }, }, 'UPDATE_ON_DUPLICATE_REG_ID': True, } - settings.FIREBASE_SETUP_STATUS = True - else: - settings.FIREBASE_SETUP_STATUS = False From af02f13259485a411e3880b801192e30a14c3808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=86=D0=B2=D0=B0=D0=BD=20=D0=9D=D1=94=D0=B4=D1=94=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=96=D1=86=D0=B5=D0=B2?= Date: Wed, 22 May 2024 13:52:37 +0300 Subject: [PATCH 2/5] fix: [AXM-475] fix device token API permissions --- lms/djangoapps/mobile_api/notifications/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/mobile_api/notifications/views.py b/lms/djangoapps/mobile_api/notifications/views.py index aeab8c5445c9..4c94ae576e76 100644 --- a/lms/djangoapps/mobile_api/notifications/views.py +++ b/lms/djangoapps/mobile_api/notifications/views.py @@ -7,7 +7,7 @@ from ..decorators import mobile_view -@mobile_view(is_user=True) +@mobile_view() class GCMDeviceViewSet(GCMDeviceViewSetBase): """ **Use Case** From 8ac6394d137963d548453c1a553ec7db3eb1d1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=86=D0=B2=D0=B0=D0=BD=20=D0=9D=D1=94=D0=B4=D1=94=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=96=D1=86=D0=B5=D0=B2?= Date: Wed, 22 May 2024 13:53:03 +0300 Subject: [PATCH 3/5] fix: [AXM-475] change texts for push notifs --- lms/templates/instructor/edx_ace/addbetatester/push/body.txt | 2 +- lms/templates/instructor/edx_ace/allowedenroll/push/body.txt | 2 +- lms/templates/instructor/edx_ace/allowedunenroll/push/body.txt | 2 +- lms/templates/instructor/edx_ace/enrolledunenroll/push/body.txt | 2 +- lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt | 2 +- lms/templates/instructor/edx_ace/removebetatester/push/body.txt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lms/templates/instructor/edx_ace/addbetatester/push/body.txt b/lms/templates/instructor/edx_ace/addbetatester/push/body.txt index 9070f05db483..6cd170cd5ce1 100644 --- a/lms/templates/instructor/edx_ace/addbetatester/push/body.txt +++ b/lms/templates/instructor/edx_ace/addbetatester/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} {% blocktrans %}Dear {{ full_name }}{% endblocktrans %} -{% blocktrans %}You have been invited to be a beta tester for {{ course_name }} at {{ site_name }} by a member of the course staff.{% endblocktrans %} +{% blocktrans %}You have been invited to be a beta tester for {{ course_name }} at {{ site_name }}.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/allowedenroll/push/body.txt b/lms/templates/instructor/edx_ace/allowedenroll/push/body.txt index cddc8d38e29b..fc2e3cce4680 100644 --- a/lms/templates/instructor/edx_ace/allowedenroll/push/body.txt +++ b/lms/templates/instructor/edx_ace/allowedenroll/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} {% blocktrans %}Dear student,{% endblocktrans %} -{% blocktrans %}You have been invited to join {{ course_name }} at {{ site_name }} by a member of the course staff.{% endblocktrans %} +{% blocktrans %}You have been invited to join {{ course_name }} at {{ site_name }}.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/allowedunenroll/push/body.txt b/lms/templates/instructor/edx_ace/allowedunenroll/push/body.txt index 5981633b96b8..b825ce1d4d18 100644 --- a/lms/templates/instructor/edx_ace/allowedunenroll/push/body.txt +++ b/lms/templates/instructor/edx_ace/allowedunenroll/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} {% blocktrans %}Dear Student,{% endblocktrans %} -{% blocktrans %}You have been unenrolled from the course {{ course_name }} by a member of the course staff. Please disregard the invitation previously sent.{% endblocktrans %} +{% blocktrans %}You have been unenrolled from the course {{ course_name }}. Please disregard the invitation previously sent.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/enrolledunenroll/push/body.txt b/lms/templates/instructor/edx_ace/enrolledunenroll/push/body.txt index da9c3a3de00c..ce94b24f6167 100644 --- a/lms/templates/instructor/edx_ace/enrolledunenroll/push/body.txt +++ b/lms/templates/instructor/edx_ace/enrolledunenroll/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} {% blocktrans %}Dear {{ full_name }}{% endblocktrans %} -{% blocktrans %}You have been unenrolled from {{ course_name }} at {{ site_name }} by a member of the course staff. This course will no longer appear on your {{ site_name }} dashboard.{% endblocktrans %} +{% blocktrans %}You have been unenrolled from {{ course_name }} at {{ site_name }}. This course will no longer appear on your {{ site_name }} dashboard.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt b/lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt index 36bd69d7b72f..883f14770512 100644 --- a/lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt +++ b/lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} {% blocktrans %}Dear {{ full_name }}{% endblocktrans %} -{% blocktrans %}You have been enrolled in {{ course_name }} at {{ site_name }} by a member of the course staff. This course will now appear on your {{ site_name }} dashboard.{% endblocktrans %} +{% blocktrans %}You have been enrolled in {{ course_name }} at {{ site_name }}. This course will now appear on your {{ site_name }} dashboard.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/removebetatester/push/body.txt b/lms/templates/instructor/edx_ace/removebetatester/push/body.txt index 586a9385f988..4806be929b83 100644 --- a/lms/templates/instructor/edx_ace/removebetatester/push/body.txt +++ b/lms/templates/instructor/edx_ace/removebetatester/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} {% blocktrans %}Dear {{ full_name }}{% endblocktrans %} -{% blocktrans %}You have been removed as a beta tester for {{ course_name }} at {{ site_name }} by a member of the course staff. This course will remain on your dashboard, but you will no longer be part of the beta testing group.{% endblocktrans %} +{% blocktrans %}You have been removed as a beta tester for {{ course_name }} at {{ site_name }}. This course will remain on your dashboard, but you will no longer be part of the beta testing group.{% endblocktrans %} {% endautoescape %} From 90e54b6ba8a01c72996b7263c5ca4e71da4c94bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=86=D0=B2=D0=B0=D0=BD=20=D0=9D=D1=94=D0=B4=D1=94=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=96=D1=86=D0=B5=D0=B2?= Date: Wed, 22 May 2024 13:58:56 +0300 Subject: [PATCH 4/5] fix: [AXM-475] update django-push-notifications version --- requirements/edx/base.txt | 5 +++-- requirements/edx/coverage.txt | 2 +- requirements/edx/development.txt | 7 ++++--- requirements/edx/doc.txt | 5 +++-- requirements/edx/github.in | 2 +- requirements/edx/testing.txt | 7 ++++--- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index f3c200ba490c..6ae34281bc2b 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -4,7 +4,7 @@ # # make upgrade # --e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications +-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications # via -r requirements/edx/github.in -e git+https://github.com/raccoongang/edx-ace.git@mob-develop#egg=edx_ace # via @@ -567,7 +567,7 @@ fastavro==1.9.4 # via openedx-events filelock==3.14.0 # via snowflake-connector-python -firebase-admin==5.0.0 +firebase-admin==6.5.0 # via edx-ace frozenlist==1.4.1 # via @@ -946,6 +946,7 @@ pyjwt[crypto]==2.8.0 # edx-drf-extensions # edx-proctoring # edx-rest-api-client + # firebase-admin # pylti1p3 # snowflake-connector-python # social-auth-core diff --git a/requirements/edx/coverage.txt b/requirements/edx/coverage.txt index e150dc3fe238..e41cc829fa37 100644 --- a/requirements/edx/coverage.txt +++ b/requirements/edx/coverage.txt @@ -8,7 +8,7 @@ chardet==5.2.0 # via diff-cover coverage==7.5.1 # via -r requirements/edx/coverage.in -diff-cover==9.0.0 +diff-cover==7.7.0 # via -r requirements/edx/coverage.in jinja2==3.1.4 # via diff-cover diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 50593bfcfe75..bcac0471454f 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -4,7 +4,7 @@ # # make upgrade # --e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications +-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications # via # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt @@ -351,7 +351,7 @@ defusedxml==0.7.1 # ora2 # python3-openid # social-auth-core -diff-cover==9.0.0 +diff-cover==7.7.0 # via -r requirements/edx/testing.txt dill==0.3.8 # via @@ -926,7 +926,7 @@ filelock==3.14.0 # snowflake-connector-python # tox # virtualenv -firebase-admin==5.0.0 +firebase-admin==6.5.0 # via # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt @@ -1651,6 +1651,7 @@ pyjwt[crypto]==2.8.0 # edx-drf-extensions # edx-proctoring # edx-rest-api-client + # firebase-admin # pylti1p3 # snowflake-connector-python # social-auth-core diff --git a/requirements/edx/doc.txt b/requirements/edx/doc.txt index e9e2d71382bc..a6d080e9e2df 100644 --- a/requirements/edx/doc.txt +++ b/requirements/edx/doc.txt @@ -4,7 +4,7 @@ # # make upgrade # --e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications +-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications # via -r requirements/edx/base.txt -e git+https://github.com/raccoongang/edx-ace.git@mob-develop#egg=edx_ace # via -r requirements/edx/base.txt @@ -653,7 +653,7 @@ filelock==3.14.0 # via # -r requirements/edx/base.txt # snowflake-connector-python -firebase-admin==5.0.0 +firebase-admin==6.5.0 # via # -r requirements/edx/base.txt # edx-ace @@ -1137,6 +1137,7 @@ pyjwt[crypto]==2.8.0 # edx-drf-extensions # edx-proctoring # edx-rest-api-client + # firebase-admin # pylti1p3 # snowflake-connector-python # social-auth-core diff --git a/requirements/edx/github.in b/requirements/edx/github.in index 7729b94e1ca3..0d81f31a051d 100644 --- a/requirements/edx/github.in +++ b/requirements/edx/github.in @@ -92,4 +92,4 @@ -e git+https://github.com/anupdhabarde/edx-proctoring-proctortrack.git@31c6c9923a51c903ae83760ecbbac191363aa2a2#egg=edx_proctoring_proctortrack -e git+https://github.com/raccoongang/edx-ace.git@mob-develop#egg=edx_ace --e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications +-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 4027fa29f3f2..ef44f63029db 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -4,7 +4,7 @@ # # make upgrade # --e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications +-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications # via -r requirements/edx/base.txt -e git+https://github.com/raccoongang/edx-ace.git@mob-develop#egg=edx_ace # via -r requirements/edx/base.txt @@ -267,7 +267,7 @@ defusedxml==0.7.1 # ora2 # python3-openid # social-auth-core -diff-cover==9.0.0 +diff-cover==7.7.0 # via -r requirements/edx/coverage.txt dill==0.3.8 # via pylint @@ -707,7 +707,7 @@ filelock==3.14.0 # snowflake-connector-python # tox # virtualenv -firebase-admin==5.0.0 +firebase-admin==6.5.0 # via # -r requirements/edx/base.txt # edx-ace @@ -1240,6 +1240,7 @@ pyjwt[crypto]==2.8.0 # edx-drf-extensions # edx-proctoring # edx-rest-api-client + # firebase-admin # pylti1p3 # snowflake-connector-python # social-auth-core From fa1d91a0ee559248886fc2900e279116d865858b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=86=D0=B2=D0=B0=D0=BD=20=D0=9D=D1=94=D0=B4=D1=94=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=96=D1=86=D0=B5=D0=B2?= Date: Wed, 22 May 2024 16:57:30 +0300 Subject: [PATCH 5/5] refactor: [AXM-475] refactor firebase settings --- .../djangoapps/ace_common/settings/common.py | 3 +- .../ace_common/settings/production.py | 31 +++++++++---------- openedx/core/djangoapps/ace_common/utils.py | 9 ++++-- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/openedx/core/djangoapps/ace_common/settings/common.py b/openedx/core/djangoapps/ace_common/settings/common.py index 9bf96a3f6dfe..dd1d5b680763 100644 --- a/openedx/core/djangoapps/ace_common/settings/common.py +++ b/openedx/core/djangoapps/ace_common/settings/common.py @@ -32,8 +32,7 @@ def plugin_settings(settings): # lint-amnesty, pylint: disable=missing-function settings.FCM_APP_NAME = 'fcm-edx-platform' settings.FIREBASE_CREDENTIALS = None - if not getattr(settings, 'FIREBASE_APP', None) and settings.FIREBASE_CREDENTIALS: - settings.FIREBASE_APP = setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME) + settings.FIREBASE_APP = setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME) if getattr(settings, 'FIREBASE_APP', None): settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH) diff --git a/openedx/core/djangoapps/ace_common/settings/production.py b/openedx/core/djangoapps/ace_common/settings/production.py index e0c3d11f4311..d3409e13f306 100644 --- a/openedx/core/djangoapps/ace_common/settings/production.py +++ b/openedx/core/djangoapps/ace_common/settings/production.py @@ -27,22 +27,21 @@ def plugin_settings(settings): settings.ACE_CHANNEL_TRANSACTIONAL_EMAIL = settings.ENV_TOKENS.get( 'ACE_CHANNEL_TRANSACTIONAL_EMAIL', settings.ACE_CHANNEL_TRANSACTIONAL_EMAIL ) - settings.FCM_APP_NAME = settings.ENV_TOKENS.get('FCM_APP_NAME', 'fcm-edx-platform') - settings.FIREBASE_CREDENTIALS = settings.ENV_TOKENS.get('FIREBASE_CREDENTIALS', {}) + settings.FCM_APP_NAME = settings.ENV_TOKENS.get('FCM_APP_NAME', settings.FCM_APP_NAME) + settings.FIREBASE_CREDENTIALS = settings.ENV_TOKENS.get('FIREBASE_CREDENTIALS', settings.FIREBASE_CREDENTIALS) - if not getattr(settings, 'FIREBASE_APP', None) and settings.FIREBASE_CREDENTIALS: - settings.FIREBASE_APP = setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME) - if settings.FIREBASE_APP: - settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH) - settings.ACE_ENABLED_POLICIES.append(settings.ACE_CHANNEL_DEFAULT_PUSH) + settings.FIREBASE_APP = setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME) + if settings.FIREBASE_APP: + settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH) + settings.ACE_ENABLED_POLICIES.append(settings.ACE_CHANNEL_DEFAULT_PUSH) - settings.PUSH_NOTIFICATIONS_SETTINGS = { - 'CONFIG': 'push_notifications.conf.AppConfig', - 'APPLICATIONS': { - settings.FCM_APP_NAME: { - 'PLATFORM': 'FCM', - 'FIREBASE_APP': settings.FIREBASE_APP, - }, + settings.PUSH_NOTIFICATIONS_SETTINGS = { + 'CONFIG': 'push_notifications.conf.AppConfig', + 'APPLICATIONS': { + settings.FCM_APP_NAME: { + 'PLATFORM': 'FCM', + 'FIREBASE_APP': settings.FIREBASE_APP, }, - 'UPDATE_ON_DUPLICATE_REG_ID': True, - } + }, + 'UPDATE_ON_DUPLICATE_REG_ID': True, + } diff --git a/openedx/core/djangoapps/ace_common/utils.py b/openedx/core/djangoapps/ace_common/utils.py index adf5586dc449..508ac4033cd1 100644 --- a/openedx/core/djangoapps/ace_common/utils.py +++ b/openedx/core/djangoapps/ace_common/utils.py @@ -15,6 +15,11 @@ def setup_firebase_app(firebase_credentials, app_name='fcm-app'): except ImportError: log.error('Could not import firebase_admin package.') return + if firebase_credentials: - certificate = firebase_admin.credentials.Certificate(firebase_credentials) - return firebase_admin.initialize_app(certificate, name=app_name) + try: + app = firebase_admin.get_app(app_name) + except ValueError: + certificate = firebase_admin.credentials.Certificate(firebase_credentials) + app = firebase_admin.initialize_app(certificate, name=app_name) + return app