mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-20 04:04:44 +00:00
mrf: defang policy modules for filtering user profile objects
This commit is contained in:
parent
0b4f569c5b
commit
75b6c4b004
2 changed files with 8 additions and 4 deletions
|
@ -105,8 +105,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
||||||
defp check_report_removal(_actor_info, object), do: {:ok, object}
|
defp check_report_removal(_actor_info, object), do: {:ok, object}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(object) do
|
def filter(%{"actor" => actor} = object) do
|
||||||
actor_info = URI.parse(object["actor"])
|
actor_info = URI.parse(actor)
|
||||||
|
|
||||||
with {:ok, object} <- check_accept(actor_info, object),
|
with {:ok, object} <- check_accept(actor_info, object),
|
||||||
{:ok, object} <- check_reject(actor_info, object),
|
{:ok, object} <- check_reject(actor_info, object),
|
||||||
|
@ -119,4 +119,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
||||||
_e -> {:reject, nil}
|
_e -> {:reject, nil}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filter(object), do: {:ok, object}
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,10 +19,12 @@ defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(object) do
|
def filter(%{"actor" => actor} = object) do
|
||||||
actor_info = URI.parse(object["actor"])
|
actor_info = URI.parse(actor)
|
||||||
allow_list = Config.get([:mrf_user_allowlist, String.to_atom(actor_info.host)], [])
|
allow_list = Config.get([:mrf_user_allowlist, String.to_atom(actor_info.host)], [])
|
||||||
|
|
||||||
filter_by_list(object, allow_list)
|
filter_by_list(object, allow_list)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filter(object), do: {:ok, object}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue