From 07f0cfa53f43954eadba9ca87398f12663b33d93 Mon Sep 17 00:00:00 2001 From: squidboi Date: Sun, 10 Jun 2018 16:40:51 -0700 Subject: [PATCH 1/7] 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} From 837792b015331f13f4aef30e8db32a41549a9597 Mon Sep 17 00:00:00 2001 From: squidboi Date: Mon, 11 Jun 2018 14:27:16 -0700 Subject: [PATCH 2/7] added CONFIGURATION.md containing some details about configuring mrf --- CONFIGURATION.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 CONFIGURATION.md diff --git a/CONFIGURATION.md b/CONFIGURATION.md new file mode 100644 index 000000000..ead5cd934 --- /dev/null +++ b/CONFIGURATION.md @@ -0,0 +1,60 @@ +# 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` + +Additionally, you can overload options in the following files: +* `dev.secret.exs`: additional custom configuration for `MIX_ENV=dev` +* `prod.secret.exs`: additional custom 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 + +Versatile policy for applying effects to 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 From 01b2dc19cc94ee0e81b7595cc06d92e31253c271 Mon Sep 17 00:00:00 2001 From: squidboi Date: Mon, 11 Jun 2018 14:29:50 -0700 Subject: [PATCH 3/7] super-minor rewording --- CONFIGURATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index ead5cd934..95eb2cab5 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -6,8 +6,8 @@ In the `config/` directory, you will find the following relevant files: * `prod.exs`: default additional configuration for `MIX_ENV=prod` Additionally, you can overload options in the following files: -* `dev.secret.exs`: additional custom configuration for `MIX_ENV=dev` -* `prod.secret.exs`: additional custom configuration for `MIX_ENV=prod` +* `dev.secret.exs`: custom additional configuration for `MIX_ENV=dev` +* `prod.secret.exs`: custom additional configuration for `MIX_ENV=prod` ## Message Rewrite Filters (MRFs) From 09214898091b851e8a30a9f40b66aa81f622b091 Mon Sep 17 00:00:00 2001 From: squidboi Date: Mon, 11 Jun 2018 14:42:57 -0700 Subject: [PATCH 4/7] more rewording --- CONFIGURATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 95eb2cab5..5d0a9a884 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -35,7 +35,7 @@ Drops all posts. It generally does not make sense to use this in production. ### SimplePolicy -Versatile policy for applying effects to posts from certain instances. +Restricts the visibility of posts from certain instances. config :pleroma, :mrf_simple, media_removal: [], From 08fc1ba382bae357f9b3bacdc692df84b55403a4 Mon Sep 17 00:00:00 2001 From: squidboi Date: Mon, 11 Jun 2018 14:59:04 -0700 Subject: [PATCH 5/7] more rewording (x2) --- CONFIGURATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 5d0a9a884..e14364912 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -5,7 +5,7 @@ In the `config/` directory, you will find the following relevant files: * `dev.exs`: default additional configuration for `MIX_ENV=dev` * `prod.exs`: default additional configuration for `MIX_ENV=prod` -Additionally, you can overload options in the following files: +You can overload options in the following files: * `dev.secret.exs`: custom additional configuration for `MIX_ENV=dev` * `prod.secret.exs`: custom additional configuration for `MIX_ENV=prod` From a2f7c0210894bc67a7b106398dcf88ad73723ea8 Mon Sep 17 00:00:00 2001 From: squidboi Date: Tue, 12 Jun 2018 21:38:28 -0700 Subject: [PATCH 6/7] split lines, explicitly advised against editing default config files --- CONFIGURATION.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index e14364912..0b5dd5419 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -5,7 +5,9 @@ In the `config/` directory, you will find the following relevant files: * `dev.exs`: default additional configuration for `MIX_ENV=dev` * `prod.exs`: default additional configuration for `MIX_ENV=prod` -You can overload options in the following files: + +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` @@ -16,14 +18,16 @@ 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. +`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. +Some policies, such as SimplePolicy and RejectNonPublic, +can be additionally configured in their respective sections. ### NoOpPolicy @@ -31,7 +35,8 @@ 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. +Drops all posts. +It generally does not make sense to use this in production. ### SimplePolicy @@ -43,9 +48,12 @@ Restricts the visibility of posts from certain instances. 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 +* `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 @@ -56,5 +64,6 @@ Drops posts with non-public visibility settings. allow_followersonly: false, allow_direct: false, -* `allow_followersonly`: whether to allow follower-only posts through the filter +* `allow_followersonly`: whether to allow follower-only posts through + the filter * `allow_direct`: whether to allow direct messages through the filter From 2586426fa0ee4732cb9d142a55bfd4f20f271fa9 Mon Sep 17 00:00:00 2001 From: squidboi Date: Tue, 12 Jun 2018 21:40:22 -0700 Subject: [PATCH 7/7] newlines --- CONFIGURATION.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 0b5dd5419..4174dd114 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -1,6 +1,7 @@ # 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` @@ -8,6 +9,7 @@ In the `config/` directory, you will find the following relevant files: 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` @@ -21,6 +23,7 @@ Modify incoming and outgoing posts. `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`