Don't let the user unfollow their own account.
This commit is contained in:
parent
aadf54e0df
commit
4db5954786
@ -167,7 +167,7 @@ defmodule Pleroma.User do
|
|||||||
|
|
||||||
def unfollow(%User{} = follower, %User{} = followed) do
|
def unfollow(%User{} = follower, %User{} = followed) do
|
||||||
ap_followers = followed.follower_address
|
ap_followers = followed.follower_address
|
||||||
if following?(follower, followed) do
|
if following?(follower, followed) and follower.ap_id != followed.ap_id do
|
||||||
following = follower.following
|
following = follower.following
|
||||||
|> List.delete(ap_followers)
|
|> List.delete(ap_followers)
|
||||||
|
|
||||||
|
@ -66,6 +66,15 @@ defmodule Pleroma.UserTest do
|
|||||||
assert user.following == []
|
assert user.following == []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "unfollow doesn't unfollow yourself" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
{:error, _} = User.unfollow(user, user)
|
||||||
|
|
||||||
|
assert user.following == [user.ap_id]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
test "test if a user is following another user" do
|
test "test if a user is following another user" do
|
||||||
followed = insert(:user)
|
followed = insert(:user)
|
||||||
user = insert(:user, %{following: [User.ap_followers(followed)]})
|
user = insert(:user, %{following: [User.ap_followers(followed)]})
|
||||||
|
Loading…
Reference in New Issue
Block a user