Implement kaniini's tweaks
authorKaren Konou <konoukaren@gmail.com>
Sun, 23 Dec 2018 11:24:53 +0000 (12:24 +0100)
committerKaren Konou <konoukaren@gmail.com>
Sun, 23 Dec 2018 11:24:53 +0000 (12:24 +0100)
lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex

index d5aa2b988254dc3837d3894f0a9c6ee5a4f30605..55d6ff3f0ffee48cb977b31197f5d7f569c03fdc 100644 (file)
@@ -2,13 +2,17 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
   @behaviour Pleroma.Web.ActivityPub.MRF
 
   @impl true
-  def filter(object) do
-    policy = Pleroma.Config.get(:mrf_hellthread)
+  def filter(%{"type" => "Create"} = object) do
+    threshold = Pleroma.Config.get([:mrf_hellthread, :threshold])
+    recipients = (object["to"] || []) ++ (object["cc"] || [])
 
-    if length(object["to"]) + length(object["cc"]) > Keyword.get(policy, :threshold) do
+    if length(recipients) > threshold do
       {:reject, nil}
     else
       {:ok, object}
     end
   end
+
+  @impl true
+  def filter(object), do: {:ok, object}
 end