From 92362e1e22a3debfaf3275822519417ee8755a7a Mon Sep 17 00:00:00 2001 From: Karen Konou Date: Sat, 22 Dec 2018 23:18:31 +0100 Subject: [PATCH] Implement large thread filter --- config/config.exs | 2 ++ .../web/activity_pub/mrf/hellthread_policy.ex | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex diff --git a/config/config.exs b/config/config.exs index 65d7346de..de834e03a 100644 --- a/config/config.exs +++ b/config/config.exs @@ -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 index 000000000..0e0918126 --- /dev/null +++ b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex @@ -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 -- 2.45.2