add the ability to 'quarantine' an activitypub peer, causing them to be treated as...
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 7 Jun 2018 03:26:41 +0000 (03:26 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 7 Jun 2018 14:38:09 +0000 (14:38 +0000)
config/config.exs
lib/pleroma/web/activity_pub/activity_pub.ex

index 826dd07b7e42a201db8617c30ed61dce2bd928d1..3292bf29c6d83b1ef3c57969ee2bbdc48b8332b8 100644 (file)
@@ -54,7 +54,8 @@ config :pleroma, :instance,
   registrations_open: true,
   federating: true,
   rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,
-  public: true
+  public: true,
+  quarantined_instances: []
 
 config :pleroma, :activitypub, accept_blocks: true
 
index 4e0be5ba2802143daa32350b2d971ccc6111e650..75a71da98bb85f25e91d1fafc0b986d81599f86e 100644 (file)
@@ -562,6 +562,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     end
   end
 
+  @quarantined_instances Keyword.get(@instance, :quarantined_instances, [])
+
+  def should_federate?(inbox, public) do
+    if public do
+      true
+    else
+      inbox_info = URI.parse(inbox)
+      inbox_info.host not in @quarantined_instances
+    end
+  end
+
   def publish(actor, activity) do
     followers =
       if actor.follower_address in activity.recipients do
@@ -571,6 +582,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
         []
       end
 
+    public = is_public?(activity)
+
     remote_inboxes =
       (Pleroma.Web.Salmon.remote_users(activity) ++ followers)
       |> Enum.filter(fn user -> User.ap_enabled?(user) end)
@@ -578,6 +591,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
         (data["endpoints"] && data["endpoints"]["sharedInbox"]) || data["inbox"]
       end)
       |> Enum.uniq()
+      |> Enum.filter(fn inbox -> should_federate?(inbox, public) end)
 
     {:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
     json = Jason.encode!(data)