From 07f0cfa53f43954eadba9ca87398f12663b33d93 Mon Sep 17 00:00:00 2001 From: squidboi Date: Sun, 10 Jun 2018 16:40:51 -0700 Subject: [PATCH] add allow_followersonly and allow_direct options for configuring mrf_rejectnonpublic --- config/config.exs | 4 +++ .../web/activity_pub/mrf/reject_non_public.ex | 26 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/config/config.exs b/config/config.exs index 3292bf29c..5e57af87b 100644 --- a/config/config.exs +++ b/config/config.exs @@ -59,6 +59,10 @@ config :pleroma, :instance, config :pleroma, :activitypub, accept_blocks: true +config :pleroma, :mrf_rejectnonpublic, + allow_followersonly: false, + allow_direct: false + config :pleroma, :mrf_simple, media_removal: [], media_nsfw: [], diff --git a/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex b/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex index 879cbe6de..b6936fe90 100644 --- a/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex +++ b/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex @@ -2,6 +2,10 @@ defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do alias Pleroma.User @behaviour Pleroma.Web.ActivityPub.MRF + @mrf_rejectnonpublic Application.get_env(:pleroma, :mrf_rejectnonpublic) + @allow_followersonly Keyword.get(@mrf_rejectnonpublic, :allow_followersonly) + @allow_direct Keyword.get(@mrf_rejectnonpublic, :allow_direct) + @impl true def filter(object) do if object["type"] == "Create" do @@ -18,9 +22,25 @@ defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do end case visibility do - "public" -> {:ok, object} - "unlisted" -> {:ok, object} - _ -> {:reject, nil} + "public" -> + {:ok, object} + + "unlisted" -> + {:ok, object} + + "followers" -> + with true <- @allow_followersonly do + {:ok, object} + else + _e -> {:reject, nil} + end + + "direct" -> + with true <- @allow_direct do + {:ok, object} + else + _e -> {:reject, nil} + end end else {:ok, object} -- 2.45.2