From 2c29329d39ded29975336902c5526a5389508536 Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Thu, 11 Oct 2018 10:35:11 +0000
Subject: [PATCH 1/3] user: local users are always AP-enabled (closes #316)

---
 lib/pleroma/user.ex | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index 02f13eb2c..70726d399 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -728,6 +728,7 @@ defmodule Pleroma.User do
     Repo.insert(cs, on_conflict: :replace_all, conflict_target: :nickname)
   end
 
+  def ap_enabled?(%User{local: true}), do: true
   def ap_enabled?(%User{info: info}), do: info["ap_enabled"]
   def ap_enabled?(_), do: false
 

From ebc32045f0e2d0baa47fb45f9bd4e6c8e3507b5d Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Thu, 11 Oct 2018 10:35:32 +0000
Subject: [PATCH 2/3] test: add regression test for #316

---
 test/user_test.exs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/test/user_test.exs b/test/user_test.exs
index 4b0f0739e..248c26a3d 100644
--- a/test/user_test.exs
+++ b/test/user_test.exs
@@ -55,6 +55,15 @@ defmodule Pleroma.UserTest do
     {:error, _} = User.follow(blockee, blocker)
   end
 
+  test "local users do not automatically follow local locked accounts" do
+    follower = insert(:user, info: %{"locked" => true})
+    followed = insert(:user, info: %{"locked" => true})
+
+    {:ok, follower} = User.maybe_direct_follow(follower, followed)
+
+    refute User.following?(follower, followed)
+  end
+
   # This is a somewhat useless test.
   # test "following a remote user will ensure a websub subscription is present" do
   #   user = insert(:user)

From 51eaece3ea68226f1780e37e46f25e74f3392782 Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Thu, 11 Oct 2018 10:49:54 +0000
Subject: [PATCH 3/3] user: break out local cases for maybe_direct_follow

---
 lib/pleroma/user.ex | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index 70726d399..db6f96daa 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -184,7 +184,15 @@ defmodule Pleroma.User do
 
   def needs_update?(_), do: true
 
-  def maybe_direct_follow(%User{} = follower, %User{info: info} = followed) do
+  def maybe_direct_follow(%User{} = follower, %User{local: true, info: %{"locked" => true}}) do
+    {:ok, follower}
+  end
+
+  def maybe_direct_follow(%User{} = follower, %User{local: true} = followed) do
+    follow(follower, followed)
+  end
+
+  def maybe_direct_follow(%User{} = follower, %User{} = followed) do
     if !User.ap_enabled?(followed) do
       follow(follower, followed)
     else