1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do
7 @moduledoc "Rejects non-public (followers-only, direct) activities"
8 @behaviour Pleroma.Web.ActivityPub.MRF
11 def filter(%{"type" => "Create"} = object) do
12 user = User.get_cached_by_ap_id(object["actor"])
13 public = "https://www.w3.org/ns/activitystreams#Public"
15 # Determine visibility
18 public in object["to"] -> "public"
19 public in object["cc"] -> "unlisted"
20 user.follower_address in object["to"] -> "followers"
24 policy = Pleroma.Config.get(:mrf_rejectnonpublic)
34 with true <- Keyword.get(policy, :allow_followersonly) do
41 with true <- Keyword.get(policy, :allow_direct) do
50 def filter(object), do: {:ok, object}