Exclude post actor from to of relay announce
authorkPherox <admin@mail.kr-kp.com>
Tue, 26 May 2020 09:47:03 +0000 (09:47 +0000)
committerkPherox <admin@mail.kr-kp.com>
Wed, 27 May 2020 14:51:15 +0000 (23:51 +0900)
lib/pleroma/web/activity_pub/builder.ex
test/web/activity_pub/relay_test.exs

index 7ece764f5ac17286cb59749aa3d67aa1e0cc0c31..51b74414ac6b8404426d2a459932f94dc249fa19 100644 (file)
@@ -7,6 +7,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do
 
   alias Pleroma.Object
   alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.Relay
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.ActivityPub.Visibility
 
@@ -85,15 +86,20 @@ defmodule Pleroma.Web.ActivityPub.Builder do
     end
   end
 
+  @spec announce(User.t(), Object.t(), keyword()) :: {:ok, map(), keyword()}
   def announce(actor, object, options \\ []) do
     public? = Keyword.get(options, :public, false)
-    to = [actor.follower_address, object.data["actor"]]
 
     to =
-      if public? do
-        [Pleroma.Constants.as_public() | to]
-      else
-        to
+      cond do
+        actor.ap_id == Relay.relay_ap_id() ->
+          [actor.follower_address]
+
+        public? ->
+          [actor.follower_address, object.data["actor"], Pleroma.Constants.as_public()]
+
+        true ->
+          [actor.follower_address, object.data["actor"]]
       end
 
     {:ok,
index dbee8a0f48122df39087a0ed391754505c51cfce..b3b573c9b87632dfae25af71955f00f3357427ac 100644 (file)
@@ -108,6 +108,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
       assert {:ok, %Activity{} = activity} = Relay.publish(note)
       assert activity.data["type"] == "Announce"
       assert activity.data["actor"] == service_actor.ap_id
+      assert activity.data["to"] == [service_actor.follower_address]
       assert called(Pleroma.Web.Federator.publish(activity))
     end