Implement large thread filter
authorKaren Konou <konoukaren@gmail.com>
Sat, 22 Dec 2018 22:18:31 +0000 (23:18 +0100)
committerKaren Konou <konoukaren@gmail.com>
Sat, 22 Dec 2018 22:18:31 +0000 (23:18 +0100)
config/config.exs
lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex [new file with mode: 0644]

index 65d7346deaee6e4a7194502c6377b7c1bd4e57d1..de834e03adede7d65c728936505d2a10b96c1265 100644 (file)
@@ -163,6 +163,8 @@ config :pleroma, :mrf_rejectnonpublic,
   allow_followersonly: false,
   allow_direct: false
 
+config :pleroma, :mrf_hellthreadmitigation, threshold: 10  
+
 config :pleroma, :mrf_simple,
   media_removal: [],
   media_nsfw: [],
diff --git a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex
new file mode 100644 (file)
index 0000000..0e09181
--- /dev/null
@@ -0,0 +1,15 @@
+defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
+  @behaviour Pleroma.Web.ActivityPub.MRF
+
+  @impl true
+  def filter(object) do
+
+    policy = Pleroma.Config.get(:mrf_hellthreadmitigation)
+
+    if (length(object["to"]) + length(object["cc"])) > Keyword.get(policy, :threshold) do
+      {:reject, nil}
+    else
+      {:ok, object}
+    end
+  end
+end
\ No newline at end of file