mrf: defang policy modules for filtering user profile objects
authorWilliam Pitcock <nenolod@dereferenced.org>
Wed, 22 May 2019 04:15:59 +0000 (04:15 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Wed, 22 May 2019 18:53:12 +0000 (18:53 +0000)
lib/pleroma/web/activity_pub/mrf/simple_policy.ex
lib/pleroma/web/activity_pub/mrf/user_allowlist.ex

index 7190652d2c832611d47c4aeffabb363f0496451a..ffaa4b7dbf6a6aa1660399d76baa1e49b1277f27 100644 (file)
@@ -105,8 +105,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
   defp check_report_removal(_actor_info, object), do: {:ok, object}
 
   @impl true
-  def filter(object) do
-    actor_info = URI.parse(object["actor"])
+  def filter(%{"actor" => actor} = object) do
+    actor_info = URI.parse(actor)
 
     with {:ok, object} <- check_accept(actor_info, object),
          {:ok, object} <- check_reject(actor_info, object),
@@ -119,4 +119,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
       _e -> {:reject, nil}
     end
   end
+
+  def filter(object), do: {:ok, object}
 end
index f5078d8182a60d35b441f5d68536bc4994653904..47663414a38773e0b1a6e860ff6055a76f43d112 100644 (file)
@@ -19,10 +19,12 @@ defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do
   end
 
   @impl true
-  def filter(object) do
-    actor_info = URI.parse(object["actor"])
+  def filter(%{"actor" => actor} = object) do
+    actor_info = URI.parse(actor)
     allow_list = Config.get([:mrf_user_allowlist, String.to_atom(actor_info.host)], [])
 
     filter_by_list(object, allow_list)
   end
+
+  def filter(object), do: {:ok, object}
 end