소스 검색

Add header image to masto api.

tags/v0.9.9
Roger Braun 6 년 전
부모
커밋
e8975d06be
2개의 변경된 파일9개의 추가작업 그리고 4개의 파일을 삭제
  1. +7
    -2
      lib/pleroma/web/mastodon_api/views/account_view.ex
  2. +2
    -2
      test/web/mastodon_api/account_view_test.exs

+ 7
- 2
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



+ 2
- 2
test/web/mastodon_api/account_view_test.exs 파일 보기

@@ -20,8 +20,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest 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})


불러오는 중...
취소
저장