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.RejectNonPublic do
6 @moduledoc "Rejects non-public (followers-only, direct) activities"
11 @behaviour Pleroma.Web.ActivityPub.MRF
13 require Pleroma.Constants
16 def filter(%{"type" => "Create"} = object) do
17 user = User.get_cached_by_ap_id(object["actor"])
19 # Determine visibility
22 Pleroma.Constants.as_public() in object["to"] -> "public"
23 Pleroma.Constants.as_public() in object["cc"] -> "unlisted"
24 user.follower_address in object["to"] -> "followers"
28 policy = Config.get(:mrf_rejectnonpublic)
31 visibility in ["public", "unlisted"] ->
34 visibility == "followers" and Keyword.get(policy, :allow_followersonly) ->
37 visibility == "direct" and Keyword.get(policy, :allow_direct) ->
46 def filter(object), do: {:ok, object}
50 do: {:ok, %{mrf_rejectnonpublic: Config.get(:mrf_rejectnonpublic) |> Enum.into(%{})}}