1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do
8 @moduledoc "Accept-list of users from specified instances"
9 @behaviour Pleroma.Web.ActivityPub.MRF
11 defp filter_by_list(object, []), do: {:ok, object}
13 defp filter_by_list(%{"actor" => actor} = object, allow_list) do
14 if actor in allow_list do
22 def filter(%{"actor" => actor} = object) do
23 actor_info = URI.parse(actor)
27 [:mrf_user_allowlist, String.to_atom(actor_info.host)],
31 filter_by_list(object, allow_list)
34 def filter(object), do: {:ok, object}
39 Config.get([:mrf_user_allowlist], [])
40 |> Enum.into(%{}, fn {k, v} -> {k, length(v)} end)
42 {:ok, %{mrf_user_allowlist: mrf_user_allowlist}}