From 70f1496eb861650d16310205cef1957fcd201948 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 18 Jul 2021 11:03:56 -0500 Subject: [PATCH] Poll notification: only notify local users --- lib/pleroma/notification.ex | 8 +++++--- test/pleroma/notification_test.exs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 4a6e5d3f9..32f13df69 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -471,9 +471,11 @@ def create_poll_notifications(%Activity{} = activity) do 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) diff --git a/test/pleroma/notification_test.exs b/test/pleroma/notification_test.exs index 0d2cacb57..3810e772b 100644 --- a/test/pleroma/notification_test.exs +++ b/test/pleroma/notification_test.exs @@ -139,7 +139,7 @@ test "create_poll_notifications/1" do {: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