diff options
author | Ariadne Conill <ariadne@dereferenced.org> | 2019-09-27 04:22:40 +0000 |
---|---|---|
committer | Ariadne Conill <ariadne@dereferenced.org> | 2019-09-27 04:22:40 +0000 |
commit | 14294243a294d764b449e1eae19c4cd87b9d4d82 (patch) | |
tree | 7cf6528e2363bbeaa352e2d93d958f9cb5e992d9 /lib | |
parent | eb9aa7aa1095de150d036839c78c402019efb4b1 (diff) | |
download | pleroma-14294243a294d764b449e1eae19c4cd87b9d4d82.tar.gz |
mastodon api: implement follow_requests_count
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/account_view.ex | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index a23aeea9b..8cf9e9d5c 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -166,6 +166,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do |> maybe_put_settings_store(user, opts[:for], opts) |> maybe_put_chat_token(user, opts[:for], opts) |> maybe_put_activation_status(user, opts[:for]) + |> maybe_put_follow_requests_count(user, opts[:for]) end defp username_from_nickname(string) when is_binary(string) do @@ -174,6 +175,21 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do defp username_from_nickname(_), do: nil + defp maybe_put_follow_requests_count( + data, + %User{id: user_id} = user, + %User{id: user_id} + ) do + count = + User.get_follow_requests(user) + |> length() + + data + |> Kernel.put_in([:follow_requests_count], count) + end + + defp maybe_put_follow_requests_count(data, _, _), do: data + defp maybe_put_settings( data, %User{id: user_id} = user, |