Merge branch 'develop' into feature/bulk-confirmation
[akkoma] / lib / pleroma / web / activity_pub / mrf / simple_policy.ex
index ffaac767e78ef4d1180d04105fe729f22e0e1396..16117772717091489ae3c7b5fa0b76e651bad7ab 100644 (file)
@@ -66,7 +66,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
            "type" => "Create",
            "object" => child_object
          } = object
-       ) do
+       )
+       when is_map(child_object) do
     media_nsfw =
       Config.get([:mrf_simple, :media_nsfw])
       |> MRF.subdomains_regex()
@@ -109,6 +110,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 +130,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