diff options
author | kaniini <ariadne@dereferenced.org> | 2019-09-29 11:44:31 +0000 |
---|---|---|
committer | kaniini <ariadne@dereferenced.org> | 2019-09-29 11:44:31 +0000 |
commit | 6d74a7528c31e6215d808627f1c393ab53d99782 (patch) | |
tree | bf49d43f003a45367145a8d58f9a857d5dc67352 /lib | |
parent | f31ad5549b4048e03171ef9ab83ed6c0815745cc (diff) | |
parent | 843c11d1f6f2455d5169952592b9b9d18be2a8fb (diff) | |
download | pleroma-6d74a7528c31e6215d808627f1c393ab53d99782.tar.gz |
Merge branch 'feature/follow-requests-count' into 'develop'
Mastodon API: add follow_requests_count
See merge request pleroma/pleroma!1726
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, |