alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MediaProxy
- defp image_url(%{"url" => [ %{ "href" => href } | _ ]}), do: href
- defp image_url(_), do: nil
-
def render("accounts.json", %{users: users} = opts) do
render_many(users, AccountView, "account.json", opts)
end
def render("account.json", %{user: user}) do
image = User.avatar_url(user) |> MediaProxy.url()
+ header = User.banner_url(user) |> MediaProxy.url()
user_info = User.user_info(user)
- header = (image_url(user.info["banner"]) || "https://placehold.it/700x335") |> MediaProxy.url()
-
%{
id: to_string(user.id),
username: hd(String.split(user.nickname, "@")),
statuses_count: 5,
note: user.bio,
url: user.ap_id,
- avatar: "https://placehold.it/48x48",
- avatar_static: "https://placehold.it/48x48",
- header: "https://placehold.it/700x335",
- header_static: "https://placehold.it/700x335",
+ avatar: "http://localhost:4001/static/avi.png",
+ avatar_static: "http://localhost:4001/static/avi.png",
+ header: "http://localhost:4001/static/banner.png",
+ header_static: "http://localhost:4001/static/banner.png",
source: %{
note: "",
privacy: "public",
{:ok, user} = User.update_follower_count(user)
Cachex.set(:user_cache, "user_info:#{user.id}", User.user_info(Repo.get!(User, user.id)))
- image = "https://placehold.it/48x48"
+ image = "http://localhost:4001/static/avi.png"
+ banner = "http://localhost:4001/static/banner.png"
represented = %{
"id" => user.id,
"statusnet_blocking" => false,
"rights" => %{},
"statusnet_profile_url" => user.ap_id,
- "cover_photo" => nil,
+ "cover_photo" => banner,
"background_image" => nil
}
test "A user for a given other follower", %{user: user} do
{:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]})
{:ok, user} = User.update_follower_count(user)
- image = "https://placehold.it/48x48"
+ image = "http://localhost:4001/static/avi.png"
+ banner = "http://localhost:4001/static/banner.png"
+
represented = %{
"id" => user.id,
"name" => user.name,
"statusnet_blocking" => false,
"rights" => %{},
"statusnet_profile_url" => user.ap_id,
- "cover_photo" => nil,
+ "cover_photo" => banner,
"background_image" => nil
}
follower = insert(:user)
{:ok, follower} = User.follow(follower, user)
{:ok, user} = User.update_follower_count(user)
- image = "https://placehold.it/48x48"
+ image = "http://localhost:4001/static/avi.png"
+ banner = "http://localhost:4001/static/banner.png"
+
represented = %{
"id" => follower.id,
"name" => follower.name,
"statusnet_blocking" => false,
"rights" => %{},
"statusnet_profile_url" => follower.ap_id,
- "cover_photo" => nil,
+ "cover_photo" => banner,
"background_image" => nil
}
user = insert(:user)
blocker = insert(:user)
User.block(blocker, user)
- image = "https://placehold.it/48x48"
+ image = "http://localhost:4001/static/avi.png"
+ banner = "http://localhost:4001/static/banner.png"
+
represented = %{
"id" => user.id,
"name" => user.name,
"statusnet_blocking" => true,
"rights" => %{},
"statusnet_profile_url" => user.ap_id,
- "cover_photo" => nil,
+ "cover_photo" => banner,
"background_image" => nil
}