activitypub: allow mastodon S2S block extension support to be disabled
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 26 May 2018 08:24:50 +0000 (08:24 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sat, 26 May 2018 08:30:41 +0000 (08:30 +0000)
config/config.exs
lib/pleroma/web/activity_pub/transmogrifier.ex

index d3f9cf6e497d6aae0a31112cf8028c0ab1958275..826dd07b7e42a201db8617c30ed61dce2bd928d1 100644 (file)
@@ -56,6 +56,8 @@ config :pleroma, :instance,
   rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,
   public: true
 
+config :pleroma, :activitypub, accept_blocks: true
+
 config :pleroma, :mrf_simple,
   media_removal: [],
   media_nsfw: [],
index 803445011357a3c464ce4b3400f16e2404e32306..eada4334e4537216dc57334529e81e06117a48cf 100644 (file)
@@ -259,6 +259,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     end
   end
 
+  @ap_config Application.get_env(:pleroma, :activitypub)
+  @accept_blocks Keyword.get(@ap_config, :accept_blocks)
+
   def handle_incoming(
         %{
           "type" => "Undo",
@@ -267,7 +270,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
           "id" => id
         } = _data
       ) do
-    with %User{local: true} = blocked <- User.get_cached_by_ap_id(blocked),
+    with true <- @accept_blocks,
+         %User{local: true} = blocked <- User.get_cached_by_ap_id(blocked),
          %User{} = blocker <- User.get_or_fetch_by_ap_id(blocker),
          {:ok, activity} <- ActivityPub.unblock(blocker, blocked, id, false) do
       User.unblock(blocker, blocked)
@@ -280,7 +284,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   def handle_incoming(
         %{"type" => "Block", "object" => blocked, "actor" => blocker, "id" => id} = data
       ) do
-    with %User{local: true} = blocked = User.get_cached_by_ap_id(blocked),
+    with true <- @accept_blocks,
+         %User{local: true} = blocked = User.get_cached_by_ap_id(blocked),
          %User{} = blocker = User.get_or_fetch_by_ap_id(blocker),
          {:ok, activity} <- ActivityPub.block(blocker, blocked, id, false) do
       User.unfollow(blocker, blocked)