aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-09-10 10:37:34 +0200
committerRoger Braun <roger@rogerbraun.net>2017-09-10 10:37:34 +0200
commite8975d06bed653f362777ee7046f8bb0129e461e (patch)
tree251c287cab3e30258e176557b4c4d7637acd6183 /lib
parentd66d69c3b429b8ad18d4247fe6abd0ee9e1a8ece (diff)
downloadpleroma-e8975d06bed653f362777ee7046f8bb0129e461e.tar.gz
Add header image to masto api.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex9
1 files changed, 7 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 5f6ca84d0..35a130b1e 100644
--- a/lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/account_view.ex
@@ -2,10 +2,15 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
use Pleroma.Web, :view
alias Pleroma.User
+ defp image_url(%{"url" => [ %{ "href" => href } | t ]}), do: href
+ defp image_url(_), do: nil
+
def render("account.json", %{user: user}) do
image = User.avatar_url(user)
user_info = User.user_info(user)
+ header = image_url(user.info["banner"]) || "https://placehold.it/700x335"
+
%{
id: user.id,
username: user.nickname,
@@ -20,8 +25,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
url: user.ap_id,
avatar: image,
avatar_static: image,
- header: "",
- header_static: ""
+ header: header,
+ header_static: header
}
end