Merge branch 'bugfix/1442-dont-return-nil-for-following-count' into 'develop'
User: Never return nil for user follower counts. Closes #1442 See merge request pleroma/pleroma!2017
This commit is contained in:
commit
cb656938ca
|
@ -74,14 +74,14 @@ defp do_render("show.json", %{user: user} = opts) do
|
||||||
|
|
||||||
following_count =
|
following_count =
|
||||||
if !user.hide_follows_count or !user.hide_follows or opts[:for] == user do
|
if !user.hide_follows_count or !user.hide_follows or opts[:for] == user do
|
||||||
user.following_count
|
user.following_count || 0
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
followers_count =
|
followers_count =
|
||||||
if !user.hide_followers_count or !user.hide_followers or opts[:for] == user do
|
if !user.hide_followers_count or !user.hide_followers or opts[:for] == user do
|
||||||
user.follower_count
|
user.follower_count || 0
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
|
@ -375,6 +375,14 @@ test "sanitizes display names" do
|
||||||
refute result.display_name == "<marquee> username </marquee>"
|
refute result.display_name == "<marquee> username </marquee>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "never display nil user follow counts" do
|
||||||
|
user = insert(:user, following_count: 0, follower_count: 0)
|
||||||
|
result = AccountView.render("show.json", %{user: user})
|
||||||
|
|
||||||
|
assert result.following_count == 0
|
||||||
|
assert result.followers_count == 0
|
||||||
|
end
|
||||||
|
|
||||||
describe "hiding follows/following" do
|
describe "hiding follows/following" do
|
||||||
test "shows when follows/followers stats are hidden and sets follow/follower count to 0" do
|
test "shows when follows/followers stats are hidden and sets follow/follower count to 0" do
|
||||||
user =
|
user =
|
||||||
|
|
Loading…
Reference in New Issue