SimplePolicy: Fix problem with DM leaks.
authorlain <lain@soykaf.club>
Fri, 31 Jul 2020 07:57:30 +0000 (09:57 +0200)
committerlain <lain@soykaf.club>
Fri, 31 Jul 2020 07:57:30 +0000 (09:57 +0200)
lib/pleroma/web/activity_pub/mrf/simple_policy.ex
test/web/activity_pub/mrf/simple_policy_test.exs

index ffaac767e78ef4d1180d04105fe729f22e0e1396..bb193475ab12a47f0aa6967584368b36b3373f33 100644 (file)
@@ -109,6 +109,10 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
     {:ok, object}
   end
 
+  defp intersection(list1, list2) do
+    list1 -- list1 -- list2
+  end
+
   defp check_followers_only(%{host: actor_host} = _actor_info, object) do
     followers_only =
       Config.get([:mrf_simple, :followers_only])
@@ -125,8 +129,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
         cc = FollowingRelationship.followers_ap_ids(user, fixed_cc)
 
         object
-        |> Map.put("to", [user.follower_address] ++ to)
-        |> Map.put("cc", cc)
+        |> Map.put("to", intersection([user.follower_address | to], fixed_to))
+        |> Map.put("cc", intersection([user.follower_address | cc], fixed_cc))
       else
         _ -> object
       end
index 9a1a7bdc8993378eed4531d0a4ad20c62e066163..d7dde62c40c8643bf2fbafc3b4fc7c08f6b17ec9 100644 (file)
@@ -308,7 +308,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
       Config.put([:mrf_simple, :followers_only], [actor_domain])
 
       assert {:ok, new_activity} = SimplePolicy.filter(activity)
-      assert actor.follower_address in new_activity["to"]
+      assert actor.follower_address in new_activity["cc"]
       assert following_user.ap_id in new_activity["to"]
       refute "https://www.w3.org/ns/activitystreams#Public" in new_activity["to"]
       refute "https://www.w3.org/ns/activitystreams#Public" in new_activity["cc"]