user_allowlist.ex (835B)
1 # Pleroma: A lightweight social networking server 2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> 3 # SPDX-License-Identifier: AGPL-3.0-only 4 5 defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do 6 alias Pleroma.Config 7 8 @moduledoc "Accept-list of users from specified instances" 9 @behaviour Pleroma.Web.ActivityPub.MRF 10 11 defp filter_by_list(object, []), do: {:ok, object} 12 13 defp filter_by_list(%{"actor" => actor} = object, allow_list) do 14 if actor in allow_list do 15 {:ok, object} 16 else 17 {:reject, nil} 18 end 19 end 20 21 @impl true 22 def filter(%{"actor" => actor} = object) do 23 actor_info = URI.parse(actor) 24 allow_list = Config.get([:mrf_user_allowlist, String.to_atom(actor_info.host)], []) 25 26 filter_by_list(object, allow_list) 27 end 28 29 def filter(object), do: {:ok, object} 30 end