Skip to content

Commit

Permalink
refactor: [AXM-252] some push notif policy refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
NiedielnitsevIvan authored and monteri committed Apr 29, 2024
1 parent 294845a commit 6e5f4fb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
31 changes: 16 additions & 15 deletions openedx/core/djangoapps/ace_common/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ 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 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)
if getattr(settings, 'FIREBASE_SETUP_STATUS', None) is 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.PUSH_NOTIFICATIONS_SETTINGS = {
'CONFIG': 'push_notifications.conf.AppConfig',
'APPLICATIONS': {
settings.FCM_APP_NAME: {
'PLATFORM': 'FCM',
'FIREBASE_APP': 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,
}
settings.FIREBASE_SETUP_STATUS = True
else:
settings.FIREBASE_SETUP_STATUS = False
5 changes: 2 additions & 3 deletions openedx/core/djangoapps/notifications/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ def check(self, message):
:return:
"""
course_ids = message.context.get('course_ids', [])
notification_type = message.context.get('notification_type', 'push')
app_label = message.context.get('app_label')

if not app_label:
if not (app_label or message.context.get('send_push_notification', False)):
return PolicyResult(deny={ChannelType.PUSH})

course_keys = [CourseKey.from_string(course_id) for course_id in course_ids]
Expand All @@ -33,7 +32,7 @@ def check(self, message):
)
push_notification_preference = course_notification_preference.get_notification_type_config(
app_label,
notification_type
notification_type='push',
).get('push', False)

if not push_notification_preference:
Expand Down

0 comments on commit 6e5f4fb

Please sign in to comment.