Commit ff2c28fd authored by William Pitcock's avatar William Pitcock

activitypub: mrf: tag policy: refactor the filtering hook a bit

parent 9a69f08e
Pipeline #7022 passed with stages
in 4 minutes and 54 seconds
......@@ -87,9 +87,8 @@ 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)
def filter_message(actor, message) do
User.get_cached_by_ap_id(actor)
|> get_tags()
|> Enum.reduce({:ok, message}, fn
tag, {:ok, message} ->
......@@ -101,17 +100,12 @@ def filter(%{"object" => target_actor, "type" => "Follow"} = message) do
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
tag, {:ok, message} ->
process_tag(tag, message)
def filter(%{"object" => target_actor, "type" => "Follow"} = message),
do: filter_message(target_actor, message)
_, error ->
error
end)
end
@impl true
def filter(%{"actor" => actor, "type" => "Create"} = message),
do: filter_message(actor, message)
@impl true
def filter(message), do: {:ok, message}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment