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,
url: user.ap_id,
avatar: image,
avatar_static: image,
- header: "",
- header_static: ""
+ header: header,
+ header_static: header
}
end
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})