fix: fix notification generated event to include only users with preferences enabled.

This commit is contained in:
SaadYousaf
2023-09-11 15:52:57 +05:00
committed by Saad Yousaf
parent 26bf329eb7
commit ca9b008a46

View File

@@ -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,
)