Minor refactoring of the logic for hiding followers/following counts.
authorMark Felder <feld@FreeBSD.org>
Mon, 14 Dec 2020 19:27:42 +0000 (13:27 -0600)
committerMark Felder <feld@FreeBSD.org>
Mon, 14 Dec 2020 19:27:42 +0000 (13:27 -0600)
Field is not nullable anymore, and this is more readable.

lib/pleroma/web/mastodon_api/views/account_view.ex

index 3158d09ed8dcd11cd10ab82292c74acd814b5ac6..026ae9458d24a301180a0aa97027fb349fd9b94e 100644 (file)
@@ -187,18 +187,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
     header_static = User.banner_url(user) |> MediaProxy.preview_url(static: true)
 
     following_count =
-      if !user.hide_follows_count or !user.hide_follows or opts[:for] == user do
-        user.following_count || 0
-      else
-        0
-      end
+      if !user.hide_follows_count or !user.hide_follows or opts[:for] == user,
+        do: user.following_count,
+        else: 0
 
     followers_count =
-      if !user.hide_followers_count or !user.hide_followers or opts[:for] == user do
-        user.follower_count || 0
-      else
-        0
-      end
+      if !user.hide_followers_count or !user.hide_followers or opts[:for] == user,
+        do: user.follower_count,
+        else: 0
 
     bot = user.actor_type == "Service"