Render multilang for attachments
This commit is contained in:
parent
64db6ce871
commit
6b20df1e2d
3 changed files with 33 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.ApiSpec.Schemas.Attachment do
|
||||
alias OpenApiSpex.Schema
|
||||
alias Pleroma.Web.ApiSpec.Helpers
|
||||
|
||||
require OpenApiSpex
|
||||
|
||||
|
@ -42,6 +43,13 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Attachment do
|
|||
description:
|
||||
"Alternate text that describes what is in the media attachment, to be used for the visually impaired or when media attachments do not load"
|
||||
},
|
||||
description_map:
|
||||
Helpers.multilang_map_of(%Schema{
|
||||
type: :string,
|
||||
nullable: true,
|
||||
description:
|
||||
"Alternate text that describes what is in the media attachment, to be used for the visually impaired or when media attachments do not load"
|
||||
}),
|
||||
type: %Schema{
|
||||
type: :string,
|
||||
enum: ["image", "video", "audio", "unknown"],
|
||||
|
@ -62,6 +70,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Attachment do
|
|||
preview_url: "someurl",
|
||||
text_url: "someurl",
|
||||
description: nil,
|
||||
description_map: %{},
|
||||
pleroma: %{mime_type: "image/png"}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -644,6 +644,7 @@ def render("attachment.json", %{attachment: attachment}) do
|
|||
text_url: href,
|
||||
type: type,
|
||||
description: attachment["name"],
|
||||
description_map: attachment["nameMap"] || %{},
|
||||
pleroma: %{mime_type: media_type},
|
||||
blurhash: attachment["blurhash"]
|
||||
}
|
||||
|
|
|
@ -654,7 +654,8 @@ test "attachments" do
|
|||
description: nil,
|
||||
pleroma: %{mime_type: "image/png"},
|
||||
meta: %{original: %{width: 200, height: 100, aspect: 2}},
|
||||
blurhash: "UJJ8X[xYW,%Jtq%NNFbXB5j]IVM|9GV=WHRn"
|
||||
blurhash: "UJJ8X[xYW,%Jtq%NNFbXB5j]IVM|9GV=WHRn",
|
||||
description_map: %{}
|
||||
}
|
||||
|
||||
api_spec = Pleroma.Web.ApiSpec.spec()
|
||||
|
@ -670,6 +671,27 @@ test "attachments" do
|
|||
assert_schema(result, "Attachment", api_spec)
|
||||
end
|
||||
|
||||
test "attachments with multilang" do
|
||||
object = %{
|
||||
"type" => "Image",
|
||||
"url" => [
|
||||
%{
|
||||
"mediaType" => "image/png",
|
||||
"href" => "someurl",
|
||||
"width" => 200,
|
||||
"height" => 100
|
||||
}
|
||||
],
|
||||
"name" => "mew mew",
|
||||
"nameMap" => %{"en" => "mew mew", "cmn" => "喵喵"},
|
||||
"blurhash" => "UJJ8X[xYW,%Jtq%NNFbXB5j]IVM|9GV=WHRn",
|
||||
"uuid" => 6
|
||||
}
|
||||
|
||||
assert %{description: "mew mew", description_map: %{"en" => "mew mew", "cmn" => "喵喵"}} =
|
||||
StatusView.render("attachment.json", %{attachment: object})
|
||||
end
|
||||
|
||||
test "put the url advertised in the Activity in to the url attribute" do
|
||||
id = "https://wedistribute.org/wp-json/pterotype/v1/object/85810"
|
||||
[activity] = Activity.search(nil, id)
|
||||
|
|
Loading…
Reference in a new issue