summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2024-02-15 00:57:34 +0100
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2024-02-15 01:18:45 +0100
commit44faf9bb623a0a153db15e5477c5426a211c5dd4 (patch)
tree2ed50e069ca36438a2c799c3ac23b01939981cd4
parent626c22961f7eb0bfc8735a11ef005e5b991f75ce (diff)
Status: Fill all MastoAPI required values in preview cardspreviewcard-void-fill
-rw-r--r--changelog.d/previewcard-void-fill.fix1
-rw-r--r--lib/pleroma/web/api_spec/schemas/status.ex49
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex7
-rw-r--r--test/pleroma/web/mastodon_api/controllers/status_controller_test.exs18
4 files changed, 68 insertions, 7 deletions
diff --git a/changelog.d/previewcard-void-fill.fix b/changelog.d/previewcard-void-fill.fix
new file mode 100644
index 000000000..04e571347
--- /dev/null
+++ b/changelog.d/previewcard-void-fill.fix
@@ -0,0 +1 @@
+Status: Fill all MastoAPI required values in preview cards
diff --git a/lib/pleroma/web/api_spec/schemas/status.ex b/lib/pleroma/web/api_spec/schemas/status.ex
index a4052803b..9700ee525 100644
--- a/lib/pleroma/web/api_spec/schemas/status.ex
+++ b/lib/pleroma/web/api_spec/schemas/status.ex
@@ -34,16 +34,40 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
type: :object,
nullable: true,
description: "Preview card for links included within status content",
- required: [:url, :title, :description, :type],
+ # Yeah, it's effectivelly all required in MastoAPI so far
+ required: [
+ :url,
+ :title,
+ :description,
+ :type,
+ :author_name,
+ :author_url,
+ :provider_name,
+ :provider_url,
+ :html,
+ :width,
+ :height,
+ :image,
+ :embed_url,
+ :blurhash
+ ],
properties: %{
+ url: %Schema{type: :string, format: :uri, description: "Location of linked resource"},
+ title: %Schema{type: :string, description: "Title of linked resource"},
+ description: %Schema{type: :string, description: "Description of preview"},
type: %Schema{
type: :string,
enum: ["link", "photo", "video", "rich"],
description: "The type of the preview card"
},
+ author_name: %Schema{type: :string, description: "author of the original resource"},
+ author_url: %Schema{
+ type: :string,
+ format: :uri,
+ description: "link to the author of the original resource"
+ },
provider_name: %Schema{
type: :string,
- nullable: true,
description: "The provider of the original resource"
},
provider_url: %Schema{
@@ -51,15 +75,30 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
format: :uri,
description: "A link to the provider of the original resource"
},
- url: %Schema{type: :string, format: :uri, description: "Location of linked resource"},
+ html: %Schema{
+ type: :string,
+ format: :html,
+ description: "HTML to be used for generating the preview card"
+ },
+ width: %Schema{type: :integer, description: "Width of preview, in pixels"},
+ height: %Schema{type: :integer, description: "Height of preview, in pixels"},
image: %Schema{
type: :string,
nullable: true,
format: :uri,
description: "Preview thumbnail"
},
- title: %Schema{type: :string, description: "Title of linked resource"},
- description: %Schema{type: :string, description: "Description of preview"}
+ embed_url: %Schema{
+ type: :string,
+ format: :uri,
+ description: "Used for photo embeds, instead of custom `html`"
+ },
+ blurhash: %Schema{
+ type: :string,
+ nullable: true,
+ description:
+ "A hash computed by the (BlurHash algorithm)[https://github.com/woltapp/blurhash], for generating colorful preview thumbnails when media has not been downloaded yet."
+ }
}
},
content: %Schema{type: :string, format: :html, description: "HTML-encoded status content"},
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 0e2e604f5..1343ab4dd 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -575,6 +575,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
image: image_url,
title: rich_media["title"] || "",
description: rich_media["description"] || "",
+ author_name: "",
+ author_url: "",
+ html: "",
+ width: 0,
+ height: 0,
+ embed_url: "",
+ blurhash: nil,
pleroma: %{
opengraph:
rich_media
diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
index 7bbe46cbe..053bf90bf 100644
--- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
@@ -1739,7 +1739,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
"description" =>
"Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer."
}
- }
+ },
+ "author_name" => "",
+ "author_url" => "",
+ "blurhash" => nil,
+ "embed_url" => "",
+ "height" => 0,
+ "html" => "",
+ "width" => 0
}
response =
@@ -1785,7 +1792,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
"type" => "website",
"url" => "https://example.com/ogp-missing-data"
}
- }
+ },
+ "author_name" => "",
+ "author_url" => "",
+ "blurhash" => nil,
+ "embed_url" => "",
+ "height" => 0,
+ "html" => "",
+ "width" => 0
}
end
end