Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
e8975d06
Commit
e8975d06
authored
Sep 10, 2017
by
lain
Browse files
Add header image to masto api.
parent
d66d69c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/mastodon_api/views/account_view.ex
View file @
e8975d06
...
...
@@ -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 @@ def render("account.json", %{user: user}) do
url:
user
.
ap_id
,
avatar:
image
,
avatar_static:
image
,
header:
""
,
header_static:
""
header:
header
,
header_static:
header
}
end
...
...
test/web/mastodon_api/account_view_test.exs
View file @
e8975d06
...
...
@@ -20,8 +20,8 @@ test "Represent a user account" do
url:
user
.
ap_id
,
avatar:
"https://placehold.it/48x48"
,
avatar_static:
"https://placehold.it/48x48"
,
header:
""
,
header_static:
""
header:
"
https://placehold.it/700x335
"
,
header_static:
"
https://placehold.it/700x335
"
}
assert
expected
==
AccountView
.
render
(
"account.json"
,
%{
user:
user
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment