mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-06-16 12:10:40 +00:00
Merge branch 'previewcard-get.remove' into 'develop'
Draft: Deprecate /api/v1/statuses/:id/card (Mastodon 3.0.0) See merge request pleroma/pleroma!4067
This commit is contained in:
commit
94392e45a3
1
changelog.d/previewcard-get.remove
Normal file
1
changelog.d/previewcard-get.remove
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Remove `/api/v1/statuses/:id/card` endpoint used for preview cards in favor of inlined in Statuses (also removed in Mastodon 3.0.0)
|
1
changelog.d/previewcard-void-fill.fix
Normal file
1
changelog.d/previewcard-void-fill.fix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Status: Fill all MastoAPI required values in preview cards
|
|
@ -339,34 +339,6 @@ defmodule Pleroma.Web.ApiSpec.StatusOperation do
|
||||||
}
|
}
|
||||||
end
|
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
|
def favourited_by_operation do
|
||||||
%Operation{
|
%Operation{
|
||||||
tags: ["Retrieve status information"],
|
tags: ["Retrieve status information"],
|
||||||
|
|
|
@ -34,16 +34,40 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
|
||||||
type: :object,
|
type: :object,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
description: "Preview card for links included within status content",
|
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: %{
|
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: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
enum: ["link", "photo", "video", "rich"],
|
enum: ["link", "photo", "video", "rich"],
|
||||||
description: "The type of the preview card"
|
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{
|
provider_name: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
nullable: true,
|
|
||||||
description: "The provider of the original resource"
|
description: "The provider of the original resource"
|
||||||
},
|
},
|
||||||
provider_url: %Schema{
|
provider_url: %Schema{
|
||||||
|
@ -51,15 +75,30 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
|
||||||
format: :uri,
|
format: :uri,
|
||||||
description: "A link to the provider of the original resource"
|
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{
|
image: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
format: :uri,
|
format: :uri,
|
||||||
description: "Preview thumbnail"
|
description: "Preview thumbnail"
|
||||||
},
|
},
|
||||||
title: %Schema{type: :string, description: "Title of linked resource"},
|
embed_url: %Schema{
|
||||||
description: %Schema{type: :string, description: "Description of preview"}
|
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"},
|
content: %Schema{type: :string, format: :html, description: "HTML-encoded status content"},
|
||||||
|
|
|
@ -473,21 +473,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "GET /api/v1/statuses/:id/card"
|
|
||||||
@deprecated "https://github.com/tootsuite/mastodon/pull/11213"
|
|
||||||
def card(
|
|
||||||
%{assigns: %{user: user}, private: %{open_api_spex: %{params: %{id: status_id}}}} = conn,
|
|
||||||
_
|
|
||||||
) do
|
|
||||||
with %Activity{} = activity <- Activity.get_by_id(status_id),
|
|
||||||
true <- Visibility.visible_for_user?(activity, user) do
|
|
||||||
data = Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)
|
|
||||||
render(conn, "card.json", data)
|
|
||||||
else
|
|
||||||
_ -> render_error(conn, :not_found, "Record not found")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@doc "GET /api/v1/statuses/:id/favourited_by"
|
@doc "GET /api/v1/statuses/:id/favourited_by"
|
||||||
def favourited_by(
|
def favourited_by(
|
||||||
%{assigns: %{user: user}, private: %{open_api_spex: %{params: %{id: id}}}} = conn,
|
%{assigns: %{user: user}, private: %{open_api_spex: %{params: %{id: id}}}} = conn,
|
||||||
|
|
|
@ -591,6 +591,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||||
image: image_url,
|
image: image_url,
|
||||||
title: rich_media["title"] || "",
|
title: rich_media["title"] || "",
|
||||||
description: rich_media["description"] || "",
|
description: rich_media["description"] || "",
|
||||||
|
author_name: "",
|
||||||
|
author_url: "",
|
||||||
|
html: "",
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
embed_url: "",
|
||||||
|
blurhash: nil,
|
||||||
pleroma: %{
|
pleroma: %{
|
||||||
opengraph:
|
opengraph:
|
||||||
rich_media
|
rich_media
|
||||||
|
|
|
@ -768,7 +768,6 @@ defmodule Pleroma.Web.Router do
|
||||||
get("/statuses", StatusController, :index)
|
get("/statuses", StatusController, :index)
|
||||||
get("/statuses/:id", StatusController, :show)
|
get("/statuses/:id", StatusController, :show)
|
||||||
get("/statuses/:id/context", StatusController, :context)
|
get("/statuses/:id/context", StatusController, :context)
|
||||||
get("/statuses/:id/card", StatusController, :card)
|
|
||||||
get("/statuses/:id/favourited_by", StatusController, :favourited_by)
|
get("/statuses/:id/favourited_by", StatusController, :favourited_by)
|
||||||
get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
|
get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
|
||||||
get("/statuses/:id/history", StatusController, :show_history)
|
get("/statuses/:id/history", StatusController, :show_history)
|
||||||
|
|
|
@ -1733,15 +1733,22 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
"description" =>
|
"description" =>
|
||||||
"Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer."
|
"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 =
|
response =
|
||||||
conn
|
conn
|
||||||
|> get("/api/v1/statuses/#{activity.id}/card")
|
|> get("/api/v1/statuses/#{activity.id}")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert response == card_data
|
assert response["card"] == card_data
|
||||||
|
|
||||||
# works with private posts
|
# works with private posts
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
|
@ -1749,10 +1756,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
|
|
||||||
response_two =
|
response_two =
|
||||||
conn
|
conn
|
||||||
|> get("/api/v1/statuses/#{activity.id}/card")
|
|> get("/api/v1/statuses/#{activity.id}")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert response_two == card_data
|
assert response_two["card"] == card_data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "replaces missing description with an empty string", %{conn: conn, user: user} do
|
test "replaces missing description with an empty string", %{conn: conn, user: user} do
|
||||||
|
@ -1762,10 +1769,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
|
|
||||||
response =
|
response =
|
||||||
conn
|
conn
|
||||||
|> get("/api/v1/statuses/#{activity.id}/card")
|
|> get("/api/v1/statuses/#{activity.id}")
|
||||||
|> json_response_and_validate_schema(:ok)
|
|> json_response_and_validate_schema(:ok)
|
||||||
|
|
||||||
assert response == %{
|
assert response["card"] == %{
|
||||||
"type" => "link",
|
"type" => "link",
|
||||||
"title" => "Pleroma",
|
"title" => "Pleroma",
|
||||||
"description" => "",
|
"description" => "",
|
||||||
|
@ -1779,7 +1786,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
"type" => "website",
|
"type" => "website",
|
||||||
"url" => "https://example.com/ogp-missing-data"
|
"url" => "https://example.com/ogp-missing-data"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"author_name" => "",
|
||||||
|
"author_url" => "",
|
||||||
|
"blurhash" => nil,
|
||||||
|
"embed_url" => "",
|
||||||
|
"height" => 0,
|
||||||
|
"html" => "",
|
||||||
|
"width" => 0
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue