aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-08-09 16:49:09 +0300
committerrinpatch <rinpatch@sdf.org>2019-08-09 16:53:55 +0300
commit409bcad54b5de631536761952faed05ad5fe3b99 (patch)
tree9cd535049299204fd906d99638ccc5b8ee1da4b6 /lib
parent29807ef6a5b43a528ffca08b4f721b251f331c8d (diff)
downloadpleroma-409bcad54b5de631536761952faed05ad5fe3b99.tar.gz
Mastodon API: Set follower/following counters to 0 when hiding
followers/following is enabled We are already doing that in AP representation, so I think we should do it here as well for consistency.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex
index de084fd6e..72c092f25 100644
--- a/lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/account_view.ex
@@ -72,6 +72,13 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
image = User.avatar_url(user) |> MediaProxy.url()
header = User.banner_url(user) |> MediaProxy.url()
user_info = User.get_cached_user_info(user)
+
+ following_count =
+ ((!user.info.hide_follows or opts[:for] == user) && user_info.following_count) || 0
+
+ followers_count =
+ ((!user.info.hide_followers or opts[:for] == user) && user_info.follower_count) || 0
+
bot = (user.info.source_data["type"] || "Person") in ["Application", "Service"]
emojis =
@@ -102,8 +109,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
display_name: display_name,
locked: user_info.locked,
created_at: Utils.to_masto_date(user.inserted_at),
- followers_count: user_info.follower_count,
- following_count: user_info.following_count,
+ followers_count: followers_count,
+ following_count: following_count,
statuses_count: user_info.note_count,
note: bio || "",
url: User.profile_url(user),