summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-07-18 11:03:56 -0500
committerAlex Gleason <alex@alexgleason.me>2021-07-18 11:03:56 -0500
commitd06e0a3312d38e24533aeb90c233f77d7712c11b (patch)
tree6685db886151cdf6ebf73e0445027cb1b19d12e3
parentf314726ea738287335b57cfa8a35c84c306c7ab0 (diff)
Poll notification: only notify local userspoll-notification-fixes
-rw-r--r--lib/pleroma/notification.ex8
-rw-r--r--test/pleroma/notification_test.exs2
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 9c7415f29..31544570f 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -471,9 +471,11 @@ defmodule Pleroma.Notification 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 @@ defmodule Pleroma.NotificationTest 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