From c44cf7d74f513397a9b25e7f7e0fe6092d679840 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Wed, 29 May 2024 06:24:24 +0200 Subject: [PATCH 1/5] StatusOperation: Remove obsolete card_operation --- .../api_spec/operations/status_operation.ex | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/lib/pleroma/web/api_spec/operations/status_operation.ex b/lib/pleroma/web/api_spec/operations/status_operation.ex index 1717c68c8..f7914406a 100644 --- a/lib/pleroma/web/api_spec/operations/status_operation.ex +++ b/lib/pleroma/web/api_spec/operations/status_operation.ex @@ -339,34 +339,6 @@ defmodule Pleroma.Web.ApiSpec.StatusOperation do } end - def card_operation do - %Operation{ - tags: ["Retrieve status information"], - deprecated: true, - summary: "Preview card", - description: "Deprecated in favor of card property inlined on Status entity", - operationId: "StatusController.card", - parameters: [id_param()], - security: [%{"oAuth" => ["read:statuses"]}], - responses: %{ - 200 => - Operation.response("Card", "application/json", %Schema{ - type: :object, - nullable: true, - properties: %{ - type: %Schema{type: :string, enum: ["link", "photo", "video", "rich"]}, - provider_name: %Schema{type: :string, nullable: true}, - provider_url: %Schema{type: :string, format: :uri}, - url: %Schema{type: :string, format: :uri}, - image: %Schema{type: :string, nullable: true, format: :uri}, - title: %Schema{type: :string}, - description: %Schema{type: :string} - } - }) - } - } - end - def favourited_by_operation do %Operation{ tags: ["Retrieve status information"], From d860d5059703bfbcd3550a8ff8361d83ec06d00d Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Wed, 29 May 2024 06:27:11 +0200 Subject: [PATCH 2/5] StatusController: Restore preview cards tests This is a partial revert of 19002fd6c11760898daf0b5ed648d6ba58d84b97 Subsequent commit updating it to cards embedded in statuses required to pass tests. --- .../controllers/status_controller_test.exs | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) 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 f34911e5b..0386a5b7a 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -1653,6 +1653,63 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do end end + describe "cards" do + setup do + Pleroma.StaticStubbedConfigMock + |> stub(:get, fn + [:rich_media, :enabled] -> true + path -> Pleroma.Test.StaticConfig.get(path) + end) + + oauth_access(["read:statuses"]) + end + + test "returns rich-media card", %{conn: conn, user: user} do + Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) + + {:ok, activity} = CommonAPI.post(user, %{status: "https://example.com/ogp"}) + + card_data = %{ + "image" => "http://ia.media-imdb.com/images/rock.jpg", + "provider_name" => "example.com", + "provider_url" => "https://example.com", + "title" => "The Rock", + "type" => "link", + "url" => "https://example.com/ogp", + "description" => + "Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer.", + "pleroma" => %{ + "opengraph" => %{ + "image" => "http://ia.media-imdb.com/images/rock.jpg", + "title" => "The Rock", + "type" => "video.movie", + "url" => "https://example.com/ogp", + "description" => + "Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer." + } + } + } + + response = + conn + |> get("/api/v1/statuses/#{activity.id}/card") + |> json_response_and_validate_schema(200) + + assert response == card_data + + # works with private posts + {:ok, activity} = + CommonAPI.post(user, %{status: "https://example.com/ogp", visibility: "direct"}) + + response_two = + conn + |> get("/api/v1/statuses/#{activity.id}/card") + |> json_response_and_validate_schema(200) + + assert response_two == card_data + end + end + test "bookmarks" do bookmarks_uri = "/api/v1/bookmarks" From c7119d17d874ad15291decc29ce1147bbdf78488 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Wed, 29 May 2024 06:24:50 +0200 Subject: [PATCH 3/5] StatusControllerTest: Update preview cards tests to current API --- .../mastodon_api/controllers/status_controller_test.exs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 0386a5b7a..08589f6ae 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -1692,10 +1692,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do response = conn - |> get("/api/v1/statuses/#{activity.id}/card") + |> get("/api/v1/statuses/#{activity.id}") |> json_response_and_validate_schema(200) - assert response == card_data + assert response["card"] == card_data # works with private posts {:ok, activity} = @@ -1703,10 +1703,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do response_two = conn - |> get("/api/v1/statuses/#{activity.id}/card") + |> get("/api/v1/statuses/#{activity.id}") |> json_response_and_validate_schema(200) - assert response_two == card_data + assert response_two["card"] == card_data end end From 656dce96dc3d4ceb2ac2fed1badc0f2baa290c7f Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 15 Feb 2024 00:57:34 +0100 Subject: [PATCH 4/5] Status: Fill all MastoAPI required values in preview cards --- changelog.d/previewcard-void-fill.fix | 1 + lib/pleroma/web/api_spec/schemas/status.ex | 49 +++++++++++++++++-- .../web/mastodon_api/views/status_view.ex | 7 +++ .../controllers/status_controller_test.exs | 44 ++++++++++++++++- 4 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 changelog.d/previewcard-void-fill.fix 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 6e537b5da..1432be264 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,7 +75,13 @@ 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, @@ -62,8 +92,17 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do type: :string, description: "Alternate text that describes what is in the 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 0c16749a4..7a654381d 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -586,6 +586,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do image_description: rich_media["image:alt"] || "", 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 08589f6ae..725356edc 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -1687,7 +1687,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 = @@ -1708,6 +1715,41 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do assert response_two["card"] == card_data end + + test "replaces missing description with an empty string", %{conn: conn, user: user} do + Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) + + {:ok, activity} = CommonAPI.post(user, %{status: "https://example.com/ogp-missing-data"}) + + response = + conn + |> get("/api/v1/statuses/#{activity.id}") + |> json_response_and_validate_schema(:ok) + + assert response["card"] == %{ + "type" => "link", + "title" => "Pleroma", + "description" => "", + "image" => nil, + "provider_name" => "example.com", + "provider_url" => "https://example.com", + "url" => "https://example.com/ogp-missing-data", + "pleroma" => %{ + "opengraph" => %{ + "title" => "Pleroma", + "type" => "website", + "url" => "https://example.com/ogp-missing-data" + } + }, + "author_name" => "", + "author_url" => "", + "blurhash" => nil, + "embed_url" => "", + "height" => 0, + "html" => "", + "width" => 0 + } + end end test "bookmarks" do From c591ca518c39eb71c41fb7b956d542bb3c4b793f Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Sun, 26 Jul 2026 13:55:57 +0400 Subject: [PATCH 5/5] fix(mastodon-api): finish preview card compatibility --- .../web/api_spec/schemas/chat_message.ex | 33 +----- .../web/api_spec/schemas/preview_card.ex | 109 ++++++++++++++++++ lib/pleroma/web/api_spec/schemas/status.ex | 76 +----------- .../web/mastodon_api/views/status_view.ex | 36 ++++-- .../controllers/status_controller_test.exs | 13 +++ .../mastodon_api/views/status_view_test.exs | 22 +++- 6 files changed, 174 insertions(+), 115 deletions(-) create mode 100644 lib/pleroma/web/api_spec/schemas/preview_card.ex diff --git a/lib/pleroma/web/api_spec/schemas/chat_message.ex b/lib/pleroma/web/api_spec/schemas/chat_message.ex index 57f7890e5..4c18063be 100644 --- a/lib/pleroma/web/api_spec/schemas/chat_message.ex +++ b/lib/pleroma/web/api_spec/schemas/chat_message.ex @@ -5,6 +5,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.ChatMessage do alias OpenApiSpex.Schema alias Pleroma.Web.ApiSpec.Schemas.Emoji + alias Pleroma.Web.ApiSpec.Schemas.PreviewCard require OpenApiSpex @@ -22,36 +23,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.ChatMessage do emojis: %Schema{type: :array, items: Emoji}, attachment: %Schema{type: :object, nullable: true}, card: %Schema{ - type: :object, - nullable: true, - description: "Preview card for links included within status content", - required: [:url, :title, :description, :type], - properties: %{ - type: %Schema{ - type: :string, - enum: ["link", "photo", "video", "rich"], - description: "The type of the preview card" - }, - provider_name: %Schema{ - type: :string, - nullable: true, - description: "The provider of the original resource" - }, - provider_url: %Schema{ - type: :string, - format: :uri, - description: "A link to the provider of the original resource" - }, - url: %Schema{type: :string, format: :uri, description: "Location of linked resource"}, - 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"} - } + allOf: [PreviewCard], + nullable: true }, unread: %Schema{type: :boolean, description: "Whether a message has been marked as read."} }, diff --git a/lib/pleroma/web/api_spec/schemas/preview_card.ex b/lib/pleroma/web/api_spec/schemas/preview_card.ex new file mode 100644 index 000000000..bb4432e18 --- /dev/null +++ b/lib/pleroma/web/api_spec/schemas/preview_card.ex @@ -0,0 +1,109 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2022 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.ApiSpec.Schemas.PreviewCard do + alias OpenApiSpex.Schema + alias Pleroma.Web.ApiSpec.Schemas.Account + + require OpenApiSpex + + OpenApiSpex.schema(%{ + title: "PreviewCard", + description: "Preview card for a link included within status or chat message content", + type: :object, + required: [ + :url, + :title, + :description, + :language, + :type, + :authors, + :author_name, + :author_url, + :provider_name, + :provider_url, + :html, + :width, + :height, + :image, + :image_description, + :embed_url, + :blurhash, + :published_at + ], + 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"}, + language: %Schema{ + type: :string, + nullable: true, + description: "Language of the linked resource" + }, + type: %Schema{ + type: :string, + enum: ["link", "photo", "video", "rich"], + description: "The type of the preview card" + }, + authors: %Schema{ + type: :array, + description: "Fediverse accounts of the authors of the original resource", + items: %Schema{ + type: :object, + required: [:name, :url, :account], + properties: %{ + name: %Schema{type: :string}, + url: %Schema{type: :string}, + account: %Schema{allOf: [Account], nullable: true} + } + } + }, + author_name: %Schema{type: :string, description: "Author of the original resource"}, + author_url: %Schema{ + type: :string, + description: "Link to the author of the original resource" + }, + provider_name: %Schema{ + type: :string, + description: "The provider of the original resource" + }, + provider_url: %Schema{ + type: :string, + description: "A link to the provider of the original 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" + }, + image_description: %Schema{ + type: :string, + description: "Alternate text that describes what is in the thumbnail" + }, + embed_url: %Schema{ + type: :string, + 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." + }, + published_at: %Schema{ + type: :string, + nullable: true, + description: "Publication date of the linked resource" + } + } + }) +end diff --git a/lib/pleroma/web/api_spec/schemas/status.ex b/lib/pleroma/web/api_spec/schemas/status.ex index 893988d18..63e9eebf0 100644 --- a/lib/pleroma/web/api_spec/schemas/status.ex +++ b/lib/pleroma/web/api_spec/schemas/status.ex @@ -9,6 +9,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do alias Pleroma.Web.ApiSpec.Schemas.Emoji alias Pleroma.Web.ApiSpec.Schemas.FlakeID alias Pleroma.Web.ApiSpec.Schemas.Poll + alias Pleroma.Web.ApiSpec.Schemas.PreviewCard alias Pleroma.Web.ApiSpec.Schemas.Tag alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope @@ -31,79 +32,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do }, bookmarked: %Schema{type: :boolean, description: "Have you bookmarked this status?"}, card: %Schema{ - type: :object, - nullable: true, - description: "Preview card for links included within status content", - # 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, - description: "The provider of the original resource" - }, - provider_url: %Schema{ - type: :string, - format: :uri, - description: "A link to the provider of the original 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" - }, - image_description: %Schema{ - type: :string, - description: "Alternate text that describes what is in the thumbnail" - }, - 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." - } - } + allOf: [PreviewCard], + nullable: true }, content: %Schema{type: :string, format: :html, description: "HTML-encoded status content"}, text: %Schema{ diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index b78494c28..356e8fce5 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -587,21 +587,25 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do video_url = proxied_url(rich_media["video"], page_url_data) %{ - type: "link", - provider_name: page_url_data.host, - provider_url: page_url_data.scheme <> "://" <> page_url_data.host, + type: card_type(rich_media["type"]), + provider_name: rich_media["provider_name"] || page_url_data.host, + provider_url: + rich_media["provider_url"] || page_url_data.scheme <> "://" <> page_url_data.host, url: page_url, image: image_url, image_description: rich_media["image:alt"] || "", title: rich_media["title"] || "", description: rich_media["description"] || "", - author_name: "", - author_url: "", - html: "", - width: 0, - height: 0, - embed_url: "", + language: nil, + authors: [], + author_name: rich_media["author_name"] || "", + author_url: rich_media["author_url"] || "", + html: rich_media["html"] || "", + width: card_dimension(rich_media["width"]), + height: card_dimension(rich_media["height"]), + embed_url: rich_media["embed_url"] || "", blurhash: nil, + published_at: nil, pleroma: %{ opengraph: rich_media @@ -706,6 +710,20 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do %{content: content, detected_source_language: detected_source_language, provider: provider} end + defp card_type(type) when type in ["link", "photo", "video", "rich"], do: type + defp card_type(_), do: "link" + + defp card_dimension(value) when is_integer(value) and value >= 0, do: value + + defp card_dimension(value) when is_binary(value) do + case Integer.parse(value) do + {dimension, ""} when dimension >= 0 -> dimension + _ -> 0 + end + end + + defp card_dimension(_), do: 0 + def get_reply_to(activity, %{replied_to_activities: replied_to_activities}) do object = Object.normalize(activity, fetch: false) 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 c70ec29c4..6ee79689d 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -2430,6 +2430,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do describe "cards" do setup do + clear_config([:rich_media, :enabled], true) + Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache) + Pleroma.StaticStubbedConfigMock |> stub(:get, fn [:rich_media, :enabled] -> true @@ -2443,6 +2446,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) {:ok, activity} = CommonAPI.post(user, %{status: "https://example.com/ogp"}) + ObanHelpers.perform_all() card_data = %{ "image" => "http://ia.media-imdb.com/images/rock.jpg", @@ -2465,10 +2469,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do }, "author_name" => "", "author_url" => "", + "authors" => [], "blurhash" => nil, "embed_url" => "", "height" => 0, "html" => "", + "image_description" => "", + "language" => nil, + "published_at" => nil, "width" => 0 } @@ -2495,6 +2503,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) {:ok, activity} = CommonAPI.post(user, %{status: "https://example.com/ogp-missing-data"}) + ObanHelpers.perform_all() response = conn @@ -2518,10 +2527,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do }, "author_name" => "", "author_url" => "", + "authors" => [], "blurhash" => nil, "embed_url" => "", "height" => 0, "html" => "", + "image_description" => "", + "language" => nil, + "published_at" => nil, "width" => 0 } end diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs index faeca050e..73adb196a 100644 --- a/test/pleroma/web/mastodon_api/views/status_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs @@ -845,15 +845,31 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do fields = %{ "url" => page_url, - "site_name" => "Example site name", + "type" => "photo", "title" => "Example website", "image" => page_url <> "/example.jpg", - "description" => "Example description" + "description" => "Example description", + "author_name" => "Example author", + "author_url" => page_url <> "/author", + "provider_name" => "Example provider", + "provider_url" => page_url <> "/provider", + "html" => "", + "width" => "1024", + "height" => 768 } {:ok, card} = Card.create(page_url, fields) - assert match?(%{provider_name: "example.com"}, StatusView.render("card.json", card)) + assert %{ + type: "photo", + author_name: "Example author", + author_url: "https://example.com/author", + provider_name: "Example provider", + provider_url: "https://example.com/provider", + html: "", + width: 1024, + height: 768 + } = StatusView.render("card.json", card) end test "a rich media card has all media proxied" do