fix: fix notification generated event to include only users with preferences enabled.
This commit is contained in:
@@ -98,6 +98,7 @@ def send_notifications(user_ids, course_key: str, app_name, notification_type, c
|
||||
)
|
||||
preferences = create_notification_pref_if_not_exists(user_ids, list(preferences), course_key)
|
||||
notifications = []
|
||||
audience = []
|
||||
for preference in preferences:
|
||||
preference = update_user_preference(preference, preference.user, course_key)
|
||||
if (
|
||||
@@ -115,12 +116,13 @@ def send_notifications(user_ids, course_key: str, app_name, notification_type, c
|
||||
course_id=course_key,
|
||||
)
|
||||
)
|
||||
audience.append(preference.user_id)
|
||||
# send notification to users but use bulk_create
|
||||
notifications_generated = Notification.objects.bulk_create(notifications)
|
||||
if notifications_generated:
|
||||
notification_content = notifications_generated[0].content
|
||||
notification_generated_event(
|
||||
user_ids, app_name, notification_type, course_key, content_url, notification_content,
|
||||
audience, app_name, notification_type, course_key, content_url, notification_content,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user