AccountView: Add user background.
This commit is contained in:
parent
6f5a0cc14e
commit
5965efb216
|
@ -125,7 +125,8 @@ defp do_render("account.json", %{user: user} = opts) do
|
||||||
hide_follows: user.info.hide_follows,
|
hide_follows: user.info.hide_follows,
|
||||||
hide_favorites: user.info.hide_favorites,
|
hide_favorites: user.info.hide_favorites,
|
||||||
relationship: relationship,
|
relationship: relationship,
|
||||||
skip_thread_containment: user.info.skip_thread_containment
|
skip_thread_containment: user.info.skip_thread_containment,
|
||||||
|
background_image: image_url(user.info.background) |> MediaProxy.url()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> maybe_put_role(user, opts[:for])
|
|> maybe_put_role(user, opts[:for])
|
||||||
|
@ -182,4 +183,7 @@ defp maybe_put_notification_settings(data, %User{id: user_id} = user, %User{id:
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_put_notification_settings(data, _, _), do: data
|
defp maybe_put_notification_settings(data, _, _), do: data
|
||||||
|
|
||||||
|
defp image_url(%{"url" => [%{"href" => href} | _]}), do: href
|
||||||
|
defp image_url(_), do: nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,9 +19,18 @@ test "Represent a user account" do
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
background_image = %{
|
||||||
|
"url" => [%{"href" => "https://example.com/images/asuka_hospital.png"}]
|
||||||
|
}
|
||||||
|
|
||||||
user =
|
user =
|
||||||
insert(:user, %{
|
insert(:user, %{
|
||||||
info: %{note_count: 5, follower_count: 3, source_data: source_data},
|
info: %{
|
||||||
|
note_count: 5,
|
||||||
|
follower_count: 3,
|
||||||
|
source_data: source_data,
|
||||||
|
background: background_image
|
||||||
|
},
|
||||||
nickname: "shp@shitposter.club",
|
nickname: "shp@shitposter.club",
|
||||||
name: ":karjalanpiirakka: shp",
|
name: ":karjalanpiirakka: shp",
|
||||||
bio: "<script src=\"invalid-html\"></script><span>valid html</span>",
|
bio: "<script src=\"invalid-html\"></script><span>valid html</span>",
|
||||||
|
@ -60,6 +69,7 @@ test "Represent a user account" do
|
||||||
pleroma: %{}
|
pleroma: %{}
|
||||||
},
|
},
|
||||||
pleroma: %{
|
pleroma: %{
|
||||||
|
background_image: "https://example.com/images/asuka_hospital.png",
|
||||||
confirmation_pending: false,
|
confirmation_pending: false,
|
||||||
tags: [],
|
tags: [],
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
|
@ -126,6 +136,7 @@ test "Represent a Service(bot) account" do
|
||||||
pleroma: %{}
|
pleroma: %{}
|
||||||
},
|
},
|
||||||
pleroma: %{
|
pleroma: %{
|
||||||
|
background_image: nil,
|
||||||
confirmation_pending: false,
|
confirmation_pending: false,
|
||||||
tags: [],
|
tags: [],
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
|
@ -216,6 +227,7 @@ test "represent an embedded relationship" do
|
||||||
pleroma: %{}
|
pleroma: %{}
|
||||||
},
|
},
|
||||||
pleroma: %{
|
pleroma: %{
|
||||||
|
background_image: nil,
|
||||||
confirmation_pending: false,
|
confirmation_pending: false,
|
||||||
tags: [],
|
tags: [],
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
|
|
Loading…
Reference in New Issue