Merge branch 'anonymize-filter-text' into 'develop'
[akkoma] / lib / pleroma / web / activity_pub / mrf / user_allowlist.ex
1 defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do
2 alias Pleroma.Config
3
4 @behaviour Pleroma.Web.ActivityPub.MRF
5
6 defp filter_by_list(object, []), do: {:ok, object}
7
8 defp filter_by_list(%{"actor" => actor} = object, allow_list) do
9 if actor in allow_list do
10 {:ok, object}
11 else
12 {:reject, nil}
13 end
14 end
15
16 @impl true
17 def filter(object) do
18 actor_info = URI.parse(object["actor"])
19 allow_list = Config.get([:mrf_user_allowlist, String.to_atom(actor_info.host)], [])
20
21 filter_by_list(object, allow_list)
22 end
23 end