Don't follow deactivated users.
This commit is contained in:
parent
b727ecc5e7
commit
a78ae2a685
2 changed files with 9 additions and 2 deletions
|
@ -142,9 +142,9 @@ defmodule Pleroma.User do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def follow(%User{} = follower, %User{} = followed) do
|
def follow(%User{} = follower, %User{info: info} = followed) do
|
||||||
ap_followers = followed.follower_address
|
ap_followers = followed.follower_address
|
||||||
if following?(follower, followed) do
|
if following?(follower, followed) or info["deactivated"] do
|
||||||
{:error,
|
{:error,
|
||||||
"Could not follow user: #{followed.nickname} is already on your list."}
|
"Could not follow user: #{followed.nickname} is already on your list."}
|
||||||
else
|
else
|
||||||
|
|
|
@ -39,6 +39,13 @@ defmodule Pleroma.UserTest do
|
||||||
assert User.ap_followers(followed) in user.following
|
assert User.ap_followers(followed) in user.following
|
||||||
end
|
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
|
test "following a remote user will ensure a websub subscription is present" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
{:ok, followed} = OStatus.make_user("shp@social.heldscal.la")
|
{:ok, followed} = OStatus.make_user("shp@social.heldscal.la")
|
||||||
|
|
Loading…
Reference in a new issue