diff options
author | lambda <pleromagit@rogerbraun.net> | 2019-02-28 07:35:26 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2019-02-28 07:35:26 +0000 |
commit | 9cc98b496ee378a2d6459b080e1d0067ac216911 (patch) | |
tree | a922bd23f4aade28e0aa1dc1a9939ec732da55fa /lib | |
parent | 14bc6bd40f0ea7879cd75444939669ee6e6ac85c (diff) | |
parent | 153664096255208055ae2e0b31ea20238ad540b2 (diff) | |
download | pleroma-9cc98b496ee378a2d6459b080e1d0067ac216911.tar.gz |
Merge branch 'feature/mastoapi-embedded-relationships' into 'develop'
mastodon api: embed relationship card under account card for Pleroma FE convenience
See merge request pleroma/pleroma!870
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/account_view.ex | 11 |
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 8fdefdebd..c32f27be2 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -32,7 +32,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do } end - def render("relationship.json", %{user: user, target: target}) do + def render("relationship.json", %{user: nil, target: _target}) do + %{} + end + + def render("relationship.json", %{user: %User{} = user, target: %User{} = target}) do follow_activity = Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(user, target) requested = @@ -85,6 +89,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do bio = HTML.filter_tags(user.bio, User.html_filter_policy(opts[:for])) + relationship = render("relationship.json", %{user: opts[:for], target: user}) + %{ id: to_string(user.id), username: username_from_nickname(user.nickname), @@ -115,7 +121,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do confirmation_pending: user_info.confirmation_pending, tags: user.tags, is_moderator: user.info.is_moderator, - is_admin: user.info.is_admin + is_admin: user.info.is_admin, + relationship: relationship } } end |