diff --git a/lib/pleroma/web/activity_pub/publisher.ex b/lib/pleroma/web/activity_pub/publisher.ex index 92d14a7da..cd820fa3d 100644 --- a/lib/pleroma/web/activity_pub/publisher.ex +++ b/lib/pleroma/web/activity_pub/publisher.ex @@ -103,7 +103,7 @@ defp signature_host(%URI{port: port, scheme: scheme, host: host}) do end end - defp should_federate?(inbox, public) do + defp should_federate?(inbox) do %{host: host} = URI.parse(inbox) quarantined_instances = @@ -188,7 +188,6 @@ def determine_inbox( def publish(%User{} = actor, %{data: %{"bcc" => bcc}} = activity) when is_list(bcc) and bcc != [] do - public = is_public?(activity) {:ok, data} = Transmogrifier.prepare_outgoing(activity.data) recipients = recipients(actor, activity) @@ -197,7 +196,7 @@ def publish(%User{} = actor, %{data: %{"bcc" => bcc}} = activity) recipients |> Enum.filter(&User.ap_enabled?/1) |> Enum.map(fn actor -> actor.inbox end) - |> Enum.filter(fn inbox -> should_federate?(inbox, public) end) + |> Enum.filter(fn inbox -> should_federate?(inbox) end) |> Instances.filter_reachable() Repo.checkout(fn -> @@ -242,7 +241,7 @@ def publish(%User{} = actor, %Activity{} = activity) do determine_inbox(activity, user) end) |> Enum.uniq() - |> Enum.filter(fn inbox -> should_federate?(inbox, public) end) + |> Enum.filter(fn inbox -> should_federate?(inbox) end) |> Instances.filter_reachable() |> Enum.each(fn {inbox, unreachable_since} -> Pleroma.Web.Federator.Publisher.enqueue_one( diff --git a/test/pleroma/web/activity_pub/publisher_test.exs b/test/pleroma/web/activity_pub/publisher_test.exs index 2cc5407aa..f6a4f5541 100644 --- a/test/pleroma/web/activity_pub/publisher_test.exs +++ b/test/pleroma/web/activity_pub/publisher_test.exs @@ -290,11 +290,18 @@ test "publish to url with with different ports" do user: actor, recipients: [follower.ap_id] ) + public_note_activity = + insert(:note_activity, + user: actor, + recipients: [follower.ap_id, @as_public] + ) res = Publisher.publish(actor, note_activity) assert res == :ok + :ok = Publisher.publish(actor, public_note_activity) + assert not called( Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ inbox: "https://domain.com/users/nick1/inbox", @@ -302,6 +309,13 @@ test "publish to url with with different ports" do id: note_activity.data["id"] }) ) + assert not called( + Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ + inbox: "https://domain.com/users/nick1/inbox", + actor_id: actor.id, + id: public_note_activity.data["id"] + }) + ) end test_with_mock "Publishes a non-public activity to non-quarantined instances.", @@ -345,6 +359,7 @@ test "publish to url with with different ports" do Pleroma.Web.Federator.Publisher, [:passthrough], [] do + Config.put([:instance, :quarantined_instances], []) follower = insert(:user, %{ local: false,