@@ -141,7 +141,6 @@ def send_notifications(user_ids, course_key: str, app_name, notification_type, c
141
141
grouping_function = NotificationRegistry .get_grouper (notification_type )
142
142
waffle_flag_enabled = ENABLE_NOTIFICATION_GROUPING .is_enabled (course_key )
143
143
grouping_enabled = waffle_flag_enabled and group_by_id and grouping_function is not None
144
- notifications_generated = False
145
144
generated_notification = None
146
145
sender_id = context .pop ('sender_id' , None )
147
146
default_web_config = get_default_values_of_preference (app_name , notification_type ).get ('web' , False )
@@ -200,20 +199,18 @@ def send_notifications(user_ids, course_key: str, app_name, notification_type, c
200
199
201
200
if grouping_enabled and existing_notifications .get (user_id , None ):
202
201
group_user_notifications (new_notification , existing_notifications [user_id ])
203
- if not notifications_generated :
204
- notifications_generated = True
202
+ if not generated_notification :
205
203
generated_notification = new_notification
206
204
else :
207
205
notifications .append (new_notification )
208
206
generated_notification_audience .append (user_id )
209
207
210
208
# send notification to users but use bulk_create
211
209
notification_objects = Notification .objects .bulk_create (notifications )
212
- if notification_objects and not notifications_generated :
213
- notifications_generated = True
210
+ if notification_objects and not generated_notification :
214
211
generated_notification = notification_objects [0 ]
215
212
216
- if notifications_generated :
213
+ if generated_notification :
217
214
notification_generated_event (
218
215
generated_notification_audience , app_name , notification_type , course_key , content_url ,
219
216
generated_notification .content , sender_id = sender_id
0 commit comments