From a78ae2a685769cbf7459eb347aca581d389018ad Mon Sep 17 00:00:00 2001 From: Lain Iwakura Date: Thu, 7 Dec 2017 17:51:55 +0100 Subject: [PATCH] Don't follow deactivated users. --- lib/pleroma/user.ex | 4 ++-- test/user_test.exs | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) 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") -- 2.45.2