aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2019-02-28 07:35:26 +0000
committerlambda <pleromagit@rogerbraun.net>2019-02-28 07:35:26 +0000
commit9cc98b496ee378a2d6459b080e1d0067ac216911 (patch)
treea922bd23f4aade28e0aa1dc1a9939ec732da55fa /lib
parent14bc6bd40f0ea7879cd75444939669ee6e6ac85c (diff)
parent153664096255208055ae2e0b31ea20238ad540b2 (diff)
downloadpleroma-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.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 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