forked from AkkomaGang/akkoma
Poll notification: only notify local users
This commit is contained in:
parent
0b1c05ca1e
commit
70f1496eb8
2 changed files with 6 additions and 4 deletions
|
@ -471,9 +471,11 @@ def create_poll_notifications(%Activity{} = activity) do
|
||||||
end
|
end
|
||||||
|
|
||||||
notifications =
|
notifications =
|
||||||
Enum.map([actor | voters], fn ap_id ->
|
Enum.reduce([actor | voters], [], fn ap_id, acc ->
|
||||||
with %User{} = user <- User.get_by_ap_id(ap_id) do
|
with %User{local: true} = user <- User.get_by_ap_id(ap_id) do
|
||||||
create_notification(activity, user, type: "poll")
|
[create_notification(activity, user, type: "poll") | acc]
|
||||||
|
else
|
||||||
|
_ -> acc
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ test "create_poll_notifications/1" do
|
||||||
|
|
||||||
{:ok, notifications} = Notification.create_poll_notifications(activity)
|
{: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
|
end
|
||||||
|
|
||||||
describe "CommonApi.post/2 notification-related functionality" do
|
describe "CommonApi.post/2 notification-related functionality" do
|
||||||
|
|
Loading…
Reference in a new issue