@@ -274,29 +274,33 @@ defmodule Algora.Activities do
274274 end
275275
276276 def notify_users ( activity , users_to_notify ) do
277- title = Views . render ( activity , :title )
278- body = Views . render ( activity , :txt )
279-
280277 email_jobs =
281- Enum . reduce ( users_to_notify , [ ] , fn
282- % { name: display_name , email: email , id: id } , acc ->
283- changeset =
284- Algora.Activities.SendEmail . changeset ( % {
285- title: title ,
286- body: body ,
287- user_id: id ,
288- activity_id: activity . id ,
289- activity_type: activity . type ,
290- activity_table: activity . assoc_name ,
291- name: display_name ,
292- email: email
293- } )
294-
295- [ changeset | acc ]
296-
297- _user , acc ->
298- acc
299- end )
278+ if users_to_notify == [ ] do
279+ [ ]
280+ else
281+ title = Views . render ( activity , :title )
282+ body = Views . render ( activity , :txt )
283+
284+ Enum . reduce ( users_to_notify , [ ] , fn
285+ % { name: display_name , email: email , id: id } , acc ->
286+ changeset =
287+ Algora.Activities.SendEmail . changeset ( % {
288+ title: title ,
289+ body: body ,
290+ user_id: id ,
291+ activity_id: activity . id ,
292+ activity_type: activity . type ,
293+ activity_table: activity . assoc_name ,
294+ name: display_name ,
295+ email: email
296+ } )
297+
298+ [ changeset | acc ]
299+
300+ _user , acc ->
301+ acc
302+ end )
303+ end
300304
301305 discord_job =
302306 if discord_payload = DiscordViews . render ( activity ) do
0 commit comments