activitypub: mrf: tag policy: add support for processing follow requests

This commit is contained in:
William Pitcock 2019-02-04 17:03:34 +00:00
parent 084bb8ccd5
commit 9a69f08e86

View file

@ -88,7 +88,20 @@ defp process_tag(
defp process_tag(_, message), do: {:ok, message} defp process_tag(_, message), do: {:ok, message}
@impl true @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) User.get_cached_by_ap_id(actor)
|> get_tags() |> get_tags()
|> Enum.reduce({:ok, message}, fn |> Enum.reduce({:ok, message}, fn
@ -99,4 +112,7 @@ def filter(%{"actor" => actor} = message) do
error error
end) end)
end end
@impl true
def filter(message), do: {:ok, message}
end end