From 9a69f08e86ce79a36dfe3d1a6f4c20b0a8a0f3c6 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 4 Feb 2019 17:03:34 +0000 Subject: [PATCH] activitypub: mrf: tag policy: add support for processing follow requests --- lib/pleroma/web/activity_pub/mrf/tag_policy.ex | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/mrf/tag_policy.ex b/lib/pleroma/web/activity_pub/mrf/tag_policy.ex index e05663371..2af36616f 100644 --- a/lib/pleroma/web/activity_pub/mrf/tag_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/tag_policy.ex @@ -88,7 +88,20 @@ defmodule Pleroma.Web.ActivityPub.MRF.TagPolicy do defp process_tag(_, message), do: {:ok, message} @impl true - def filter(%{"actor" => actor} = message) do + 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 User.get_cached_by_ap_id(actor) |> get_tags() |> Enum.reduce({:ok, message}, fn @@ -99,4 +112,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.TagPolicy do error end) end + + @impl true + def filter(message), do: {:ok, message} end -- 2.45.2