From: Lain Iwakura Date: Thu, 7 Dec 2017 16:51:55 +0000 (+0100) Subject: Don't follow deactivated users. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=a78ae2a685769cbf7459eb347aca581d389018ad;p=akkoma Don't follow deactivated users. --- diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 779a89a12..b21caba9d 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -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 diff --git a/test/user_test.exs b/test/user_test.exs index 6daf1ecb7..486998907 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -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")