aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2018-06-16 10:39:36 +0000
committerlambda <pleromagit@rogerbraun.net>2018-06-16 10:39:36 +0000
commit1ea4a18ad859600841860cdd1a981da868aa18a0 (patch)
treec498b0fb3c5297d0a6e6e9627ef233c11fc227eb
parenta938d07df1679efd78e1b7c10e149270489761f7 (diff)
parent2586426fa0ee4732cb9d142a55bfd4f20f271fa9 (diff)
downloadpleroma-1ea4a18ad859600841860cdd1a981da868aa18a0.tar.gz
Merge branch 'feature/configure-mrf-rejectnonpublic' into 'develop'
Configs for mrf_rejectnonpublic See merge request pleroma/pleroma!205
-rw-r--r--CONFIGURATION.md72
-rw-r--r--config/config.exs4
-rw-r--r--lib/pleroma/web/activity_pub/mrf/reject_non_public.ex26
3 files changed, 99 insertions, 3 deletions
diff --git a/CONFIGURATION.md b/CONFIGURATION.md
new file mode 100644
index 000000000..4174dd114
--- /dev/null
+++ b/CONFIGURATION.md
@@ -0,0 +1,72 @@
+# Configuring Pleroma
+
+In the `config/` directory, you will find the following relevant files:
+
+* `config.exs`: default base configuration
+* `dev.exs`: default additional configuration for `MIX_ENV=dev`
+* `prod.exs`: default additional configuration for `MIX_ENV=prod`
+
+
+Do not modify files in the list above.
+Instead, overload the settings by editing the following files:
+
+* `dev.secret.exs`: custom additional configuration for `MIX_ENV=dev`
+* `prod.secret.exs`: custom additional configuration for `MIX_ENV=prod`
+
+## Message Rewrite Filters (MRFs)
+
+Modify incoming and outgoing posts.
+
+ config :pleroma, :instance,
+ rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy
+
+`rewrite_policy` specifies which MRF policies to apply.
+It can either be a single policy or a list of policies.
+Currently, MRFs availible by default are:
+
+* `Pleroma.Web.ActivityPub.MRF.NoOpPolicy`
+* `Pleroma.Web.ActivityPub.MRF.DropPolicy`
+* `Pleroma.Web.ActivityPub.MRF.SimplePolicy`
+* `Pleroma.Web.ActivityPub.MRF.RejectNonPublic`
+
+Some policies, such as SimplePolicy and RejectNonPublic,
+can be additionally configured in their respective sections.
+
+### NoOpPolicy
+
+Does not modify posts (this is the default `rewrite_policy`)
+
+### DropPolicy
+
+Drops all posts.
+It generally does not make sense to use this in production.
+
+### SimplePolicy
+
+Restricts the visibility of posts from certain instances.
+
+ config :pleroma, :mrf_simple,
+ media_removal: [],
+ media_nsfw: [],
+ federated_timeline_removal: [],
+ reject: []
+
+* `media_removal`: posts from these instances will have attachments
+ removed
+* `media_nsfw`: posts from these instances will have attachments marked
+ as nsfw
+* `federated_timeline_removal`: posts from these instances will be
+ marked as unlisted
+* `reject`: posts from these instances will be dropped
+
+### RejectNonPublic
+
+Drops posts with non-public visibility settings.
+
+ config :pleroma :mrf_rejectnonpublic
+ allow_followersonly: false,
+ allow_direct: false,
+
+* `allow_followersonly`: whether to allow follower-only posts through
+ the filter
+* `allow_direct`: whether to allow direct messages through the filter
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}