activitypub: only send accept back automatically if the account is not locked
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 26 May 2018 14:55:16 +0000 (14:55 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 11 Jun 2018 22:15:27 +0000 (22:15 +0000)
lib/pleroma/user.ex
lib/pleroma/web/activity_pub/transmogrifier.ex

index 00cac153d1d0dd10843d7f10a94f1660a8d21fba..c7b7b4f0a0cf5491b5158867ee909811dfec7f4d 100644 (file)
@@ -252,6 +252,10 @@ defmodule Pleroma.User do
     Enum.member?(follower.following, followed.follower_address)
   end
 
+  def locked?(%User{} = user) do
+    user.info["locked"] || false
+  end
+
   def get_by_ap_id(ap_id) do
     Repo.get_by(User, ap_id: ap_id)
   end
index 75ba367297d474107ac2354f78640407c9368507..7b0d124b26ce3bede04bfed8ccf84d8c9f34a3d4 100644 (file)
@@ -137,9 +137,11 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     with %User{local: true} = followed <- User.get_cached_by_ap_id(followed),
          %User{} = follower <- User.get_or_fetch_by_ap_id(follower),
          {:ok, activity} <- ActivityPub.follow(follower, followed, id, false) do
-      ActivityPub.accept(%{to: [follower.ap_id], actor: followed.ap_id, object: data, local: true})
+      if not User.locked?(followed) do
+        ActivityPub.accept(%{to: [follower.ap_id], actor: followed.ap_id, object: data, local: true})
+        User.follow(follower, followed)
+      end
 
-      User.follow(follower, followed)
       {:ok, activity}
     else
       _e -> :error