Use absolute URLs to thumbnail and background in /api/v1/instance

This commit is contained in:
Mark Felder 2020-11-16 21:29:15 +00:00
parent 28da36975d
commit b1466661eb
2 changed files with 9 additions and 4 deletions

View file

@ -23,7 +23,7 @@ def render("show.json", _) do
streaming_api: Pleroma.Web.Endpoint.websocket_url() streaming_api: Pleroma.Web.Endpoint.websocket_url()
}, },
stats: Pleroma.Stats.get_stats(), stats: Pleroma.Stats.get_stats(),
thumbnail: Keyword.get(instance, :instance_thumbnail), thumbnail: Pleroma.Web.base_url() <> Keyword.get(instance, :instance_thumbnail),
languages: ["en"], languages: ["en"],
registrations: Keyword.get(instance, :registrations_open), registrations: Keyword.get(instance, :registrations_open),
approval_required: Keyword.get(instance, :account_approval_required), approval_required: Keyword.get(instance, :account_approval_required),
@ -34,7 +34,7 @@ def render("show.json", _) do
avatar_upload_limit: Keyword.get(instance, :avatar_upload_limit), avatar_upload_limit: Keyword.get(instance, :avatar_upload_limit),
background_upload_limit: Keyword.get(instance, :background_upload_limit), background_upload_limit: Keyword.get(instance, :background_upload_limit),
banner_upload_limit: Keyword.get(instance, :banner_upload_limit), banner_upload_limit: Keyword.get(instance, :banner_upload_limit),
background_image: Keyword.get(instance, :background_image), background_image: Pleroma.Web.base_url() <> Keyword.get(instance, :background_image),
chat_limit: Keyword.get(instance, :chat_limit), chat_limit: Keyword.get(instance, :chat_limit),
description_limit: Keyword.get(instance, :description_limit), description_limit: Keyword.get(instance, :description_limit),
pleroma: %{ pleroma: %{

View file

@ -13,6 +13,9 @@ test "get instance information", %{conn: conn} do
assert result = json_response_and_validate_schema(conn, 200) assert result = json_response_and_validate_schema(conn, 200)
email = Pleroma.Config.get([:instance, :email]) email = Pleroma.Config.get([:instance, :email])
thumbnail = Pleroma.Web.base_url() <> Pleroma.Config.get([:instance, :instance_thumbnail])
background = Pleroma.Web.base_url() <> Pleroma.Config.get([:instance, :background_image])
# Note: not checking for "max_toot_chars" since it's optional # Note: not checking for "max_toot_chars" since it's optional
assert %{ assert %{
"uri" => _, "uri" => _,
@ -24,7 +27,7 @@ test "get instance information", %{conn: conn} do
"streaming_api" => _ "streaming_api" => _
}, },
"stats" => _, "stats" => _,
"thumbnail" => _, "thumbnail" => from_config_thumbnail,
"languages" => _, "languages" => _,
"registrations" => _, "registrations" => _,
"approval_required" => _, "approval_required" => _,
@ -33,7 +36,7 @@ test "get instance information", %{conn: conn} do
"avatar_upload_limit" => _, "avatar_upload_limit" => _,
"background_upload_limit" => _, "background_upload_limit" => _,
"banner_upload_limit" => _, "banner_upload_limit" => _,
"background_image" => _, "background_image" => from_config_background,
"chat_limit" => _, "chat_limit" => _,
"description_limit" => _ "description_limit" => _
} = result } = result
@ -45,6 +48,8 @@ test "get instance information", %{conn: conn} do
assert result["pleroma"]["vapid_public_key"] assert result["pleroma"]["vapid_public_key"]
assert email == from_config_email assert email == from_config_email
assert thumbnail == from_config_thumbnail
assert background == from_config_background
end end
test "get instance stats", %{conn: conn} do test "get instance stats", %{conn: conn} do