Don't follow deactivated users.
authorLain Iwakura <lain@soykaf.club>
Thu, 7 Dec 2017 16:51:55 +0000 (17:51 +0100)
committerLain Iwakura <lain@soykaf.club>
Thu, 7 Dec 2017 16:51:55 +0000 (17:51 +0100)
lib/pleroma/user.ex
test/user_test.exs

index 779a89a12771cc1649a280166c865b756340ccc5..b21caba9d3517766e6c05cfad65a72bf599b175f 100644 (file)
@@ -142,9 +142,9 @@ defmodule Pleroma.User do
     end
   end
 
-  def follow(%User{} = follower, %User{} = followed) do
+  def follow(%User{} = follower, %User{info: info} = followed) do
     ap_followers = followed.follower_address
-    if following?(follower, followed) do
+    if following?(follower, followed) or info["deactivated"] do
       {:error,
        "Could not follow user: #{followed.nickname} is already on your list."}
     else
index 6daf1ecb7cd60bce83102417a714e3d6ca08a5e9..4869989073ba8072add492b3560db2dfd73daaf9 100644 (file)
@@ -39,6 +39,13 @@ defmodule Pleroma.UserTest do
     assert User.ap_followers(followed) in user.following
   end
 
+  test "can't follow a deactivated users" do
+    user = insert(:user)
+    followed = insert(:user, info: %{"deactivated" => true})
+
+    {:error, _} = User.follow(user, followed)
+  end
+
   test "following a remote user will ensure a websub subscription is present" do
     user = insert(:user)
     {:ok, followed} = OStatus.make_user("shp@social.heldscal.la")