From 8d4e7b32c9adc2b16eaec93f4e6d754a2ace45b3 Mon Sep 17 00:00:00 2001 From: eal Date: Mon, 20 Nov 2017 09:26:31 +0200 Subject: [PATCH 1/2] Ensure correct state in self-unfollow. --- test/user_test.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/user_test.exs b/test/user_test.exs index 8ec23c751..31c5962e2 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -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 From e9037ffc8d38d905c746a30128ab8ca930acbcd1 Mon Sep 17 00:00:00 2001 From: eal Date: Tue, 21 Nov 2017 15:33:09 +0200 Subject: [PATCH 2/2] Do not include user in their own follower count. --- lib/pleroma/user.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index f80c0ae33..68ffe184b 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -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)