diff options
author | eugenijm <eugenijm@protonmail.com> | 2019-10-02 00:37:08 +0300 |
---|---|---|
committer | eugenijm <eugenijm@protonmail.com> | 2019-10-04 00:53:23 +0300 |
commit | 06d9df79c5c99069dd12e863c99167eb20b6495b (patch) | |
tree | 28a318577f31aef00a01ff321119117dbc44f10c /lib/pleroma/web/mastodon_api | |
parent | 4fe2af3b2d6b0701de2ae88f9932e4b6039ced11 (diff) | |
download | pleroma-06d9df79c5c99069dd12e863c99167eb20b6495b.tar.gz |
Mastodon API: Add `pleroma.unread_conversation_count` to the Account entity
Diffstat (limited to 'lib/pleroma/web/mastodon_api')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/account_view.ex | 11 |
1 files changed, 11 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 99169ef95..2d4976891 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -167,6 +167,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do |> maybe_put_chat_token(user, opts[:for], opts) |> maybe_put_activation_status(user, opts[:for]) |> maybe_put_follow_requests_count(user, opts[:for]) + |> maybe_put_unread_conversation_count(user, opts[:for]) end defp username_from_nickname(string) when is_binary(string) do @@ -248,6 +249,16 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do defp maybe_put_activation_status(data, _, _), do: data + defp maybe_put_unread_conversation_count(data, %User{id: user_id} = user, %User{id: user_id}) do + data + |> Kernel.put_in( + [:pleroma, :unread_conversation_count], + user.info.unread_conversation_count + ) + end + + defp maybe_put_unread_conversation_count(data, _, _), do: data + defp image_url(%{"url" => [%{"href" => href} | _]}), do: href defp image_url(_), do: nil end |