Merge branch 'fix/self-follow' into 'develop'

Dont include the user in their own follower count.

See merge request pleroma/pleroma!29
This commit is contained in:
eal 2017-11-21 23:09:59 +00:00
commit 1625021a9c
2 changed files with 2 additions and 0 deletions

View file

@ -265,6 +265,7 @@ def update_note_count(%User{} = user) do
def update_follower_count(%User{} = user) do
follower_count_query = from u in User,
where: fragment("? @> ?", u.following, ^user.follower_address),
where: u.id != ^user.id,
select: count(u.id)
follower_count = Repo.one(follower_count_query)

View file

@ -71,6 +71,7 @@ test "unfollow doesn't unfollow yourself" do
{:error, _} = User.unfollow(user, user)
user = Repo.get(User, user.id)
assert user.following == [user.ap_id]
end