aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-06-19 21:23:37 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-06-19 21:28:24 +0000
commit60d6038be57aaa90f1d8ba9a05ecbee03b59fc82 (patch)
tree272e870fa168507f2c7aaa8702e3bdfa831f0b61
parent90cf75f4a781f2eb7016a4a165a8617d4352451b (diff)
downloadpleroma-60d6038be57aaa90f1d8ba9a05ecbee03b59fc82.tar.gz
mrf simple: add accept lists
accept lists supplement reject lists by requiring that any message accepted by contained by the accept list. in other words, this functionality can be used to implement instances similar to awoo.space.
-rw-r--r--CONFIGURATION.md4
-rw-r--r--config/config.exs3
-rw-r--r--lib/pleroma/web/activity_pub/mrf/simple_policy.ex12
3 files changed, 16 insertions, 3 deletions
diff --git a/CONFIGURATION.md b/CONFIGURATION.md
index 4174dd114..6b2821b21 100644
--- a/CONFIGURATION.md
+++ b/CONFIGURATION.md
@@ -49,7 +49,8 @@ Restricts the visibility of posts from certain instances.
media_removal: [],
media_nsfw: [],
federated_timeline_removal: [],
- reject: []
+ reject: [],
+ accept: []
* `media_removal`: posts from these instances will have attachments
removed
@@ -58,6 +59,7 @@ Restricts the visibility of posts from certain instances.
* `federated_timeline_removal`: posts from these instances will be
marked as unlisted
* `reject`: posts from these instances will be dropped
+* `accept`: if not empty, only posts from these instances will be accepted
### RejectNonPublic
diff --git a/config/config.exs b/config/config.exs
index 5e57af87b..6fc127d4c 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -67,7 +67,8 @@ config :pleroma, :mrf_simple,
media_removal: [],
media_nsfw: [],
federated_timeline_removal: [],
- reject: []
+ reject: [],
+ accept: []
config :pleroma, :media_proxy,
enabled: false,
diff --git a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
index 8d770387d..0a047013a 100644
--- a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
+++ b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
@@ -4,6 +4,15 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
@mrf_policy Application.get_env(:pleroma, :mrf_simple)
+ @accept Keyword.get(@mrf_policy, :accept)
+ defp check_accept(actor_info, object) do
+ if length(@accept) > 0 and not actor_info.host in @accept do
+ {:reject, nil}
+ else
+ {:ok, object}
+ end
+ end
+
@reject Keyword.get(@mrf_policy, :reject)
defp check_reject(actor_info, object) do
if actor_info.host in @reject do
@@ -74,7 +83,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
def filter(object) do
actor_info = URI.parse(object["actor"])
- with {:ok, object} <- check_reject(actor_info, object),
+ with {:ok, object} <- check_accept(actor_info, object),
+ {:ok, object} <- check_reject(actor_info, object),
{:ok, object} <- check_media_removal(actor_info, object),
{:ok, object} <- check_media_nsfw(actor_info, object),
{:ok, object} <- check_ftl_removal(actor_info, object) do