commit: d4b889783c9ab8e73ba02b9c3bf1e36350de7b3c
parent 8bc59e9743534f1be5a751ea857c74a5637f63ed
Author: feld <feld@feld.me>
Date: Thu, 11 Jan 2024 20:21:57 +0000
Merge branch 'fix-duplicate-inbox-deliveries' into 'develop'
Fix duplicate inbox deliveries
See merge request pleroma/pleroma!4031
Diffstat:
3 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/changelog.d/fix-duplicate-inbox-deliveries.fix b/changelog.d/fix-duplicate-inbox-deliveries.fix
diff --git a/lib/pleroma/web/activity_pub/publisher.ex b/lib/pleroma/web/activity_pub/publisher.ex
@@ -255,7 +255,10 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
[priority_recipients, recipients]
|> Enum.map(fn recipients ->
recipients
- |> Enum.map(fn actor -> actor.inbox end)
+ |> Enum.map(fn %User{} = user ->
+ determine_inbox(activity, user)
+ end)
+ |> Enum.uniq()
|> Enum.filter(fn inbox -> should_federate?(inbox, public) end)
|> Instances.filter_reachable()
end)
@@ -302,7 +305,10 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
recipients(actor, activity)
|> Enum.map(fn recipients ->
recipients
- |> Enum.map(fn actor -> actor.inbox end)
+ |> Enum.map(fn %User{} = user ->
+ determine_inbox(activity, user)
+ end)
+ |> Enum.uniq()
|> Enum.filter(fn inbox -> should_federate?(inbox, public) end)
end)
diff --git a/test/pleroma/web/federator_test.exs b/test/pleroma/web/federator_test.exs
@@ -40,6 +40,44 @@ defmodule Pleroma.Web.FederatorTest do
%{activity: activity, relay_mock: relay_mock}
end
+ test "to shared inbox when multiple actors from same instance are recipients" do
+ user = insert(:user)
+
+ shared_inbox = "https://domain.com/inbox"
+
+ follower_one =
+ insert(:user, %{
+ local: false,
+ nickname: "nick1@domain.com",
+ ap_id: "https://domain.com/users/nick1",
+ inbox: "https://domain.com/users/nick1/inbox",
+ shared_inbox: shared_inbox
+ })
+
+ follower_two =
+ insert(:user, %{
+ local: false,
+ nickname: "nick2@domain.com",
+ ap_id: "https://domain.com/users/nick2",
+ inbox: "https://domain.com/users/nick2/inbox",
+ shared_inbox: shared_inbox
+ })
+
+ {:ok, _, _} = Pleroma.User.follow(follower_one, user)
+ {:ok, _, _} = Pleroma.User.follow(follower_two, user)
+
+ {:ok, _activity} = CommonAPI.post(user, %{status: "Happy Friday everyone!"})
+
+ ObanHelpers.perform(all_enqueued(worker: PublisherWorker))
+
+ inboxes =
+ all_enqueued(worker: PublisherWorker)
+ |> Enum.filter(&(get_in(&1, [Access.key(:args), Access.key("op")]) == "publish_one"))
+ |> Enum.map(&get_in(&1, [Access.key(:args), Access.key("params"), Access.key("inbox")]))
+
+ assert [shared_inbox] == inboxes
+ end
+
test "with relays active, it publishes to the relay", %{
activity: activity,
relay_mock: relay_mock