From ff2c28fd6d58b0985e8d59dfbe4ee0d52544e8b3 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 4 Feb 2019 17:06:37 +0000 Subject: [PATCH] activitypub: mrf: tag policy: refactor the filtering hook a bit --- .../web/activity_pub/mrf/tag_policy.ex | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/pleroma/web/activity_pub/mrf/tag_policy.ex b/lib/pleroma/web/activity_pub/mrf/tag_policy.ex index 2af36616f..dd3129707 100644 --- a/lib/pleroma/web/activity_pub/mrf/tag_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/tag_policy.ex @@ -87,21 +87,7 @@ defp process_tag( defp process_tag(_, message), do: {:ok, message} - @impl true - def filter(%{"object" => target_actor, "type" => "Follow"} = message) do - User.get_cached_by_ap_id(target_actor) - |> get_tags() - |> Enum.reduce({:ok, message}, fn - tag, {:ok, message} -> - process_tag(tag, message) - - _, error -> - error - end) - end - - @impl true - def filter(%{"actor" => actor, "type" => "Create"} = message) do + def filter_message(actor, message) do User.get_cached_by_ap_id(actor) |> get_tags() |> Enum.reduce({:ok, message}, fn @@ -113,6 +99,14 @@ def filter(%{"actor" => actor, "type" => "Create"} = message) do end) end + @impl true + def filter(%{"object" => target_actor, "type" => "Follow"} = message), + do: filter_message(target_actor, message) + + @impl true + def filter(%{"actor" => actor, "type" => "Create"} = message), + do: filter_message(actor, message) + @impl true def filter(message), do: {:ok, message} end