end
notifications =
- Enum.map([actor | voters], fn ap_id ->
- with %User{} = user <- User.get_by_ap_id(ap_id) do
- create_notification(activity, user, type: "poll")
+ Enum.reduce([actor | voters], [], fn ap_id, acc ->
+ with %User{local: true} = user <- User.get_by_ap_id(ap_id) do
+ [create_notification(activity, user, type: "poll") | acc]
+ else
+ _ -> acc
end
end)
{:ok, notifications} = Notification.create_poll_notifications(activity)
- assert [user1.id, user3.id, user2.id] == Enum.map(notifications, & &1.user_id)
+ assert [user2.id, user3.id, user1.id] == Enum.map(notifications, & &1.user_id)
end
describe "CommonApi.post/2 notification-related functionality" do