mirror of
https://git.pleroma.social/sjw/pleroma.git
synced 2024-11-15 23:26:17 +01:00
activitypub: mrf: tag policy: refactor the filtering hook a bit
This commit is contained in:
parent
9a69f08e86
commit
ff2c28fd6d
@ -87,21 +87,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.TagPolicy do
|
||||
|
||||
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 @@ defmodule Pleroma.Web.ActivityPub.MRF.TagPolicy 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
|
||||
|
Loading…
Reference in New Issue
Block a user