Skip to content

Commit 19002fd

Browse files
committed
Mastodon API: Remove deprecated GET /api/v1/statuses/:id/card endpoint
Removed back in 2019 mastodon/mastodon#11213
1 parent 37de588 commit 19002fd

4 files changed

Lines changed: 1 addition & 75 deletions

File tree

changelog.d/card-endpoint.remove

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Mastodon API: Remove deprecated GET /api/v1/statuses/:id/card endpoint https://github.com/mastodon/mastodon/pull/11213

lib/pleroma/web/mastodon_api/controllers/status_controller.ex

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
2525
alias Pleroma.Web.OAuth.Token
2626
alias Pleroma.Web.Plugs.OAuthScopesPlug
2727
alias Pleroma.Web.Plugs.RateLimiter
28-
alias Pleroma.Web.RichMedia.Card
2928

3029
plug(Pleroma.Web.ApiSpec.CastAndValidate, replace_params: false)
3130

@@ -39,7 +38,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
3938
when action in [
4039
:index,
4140
:show,
42-
:card,
4341
:context,
4442
:show_history,
4543
:show_source
@@ -474,21 +472,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
474472
end
475473
end
476474

477-
@doc "GET /api/v1/statuses/:id/card"
478-
@deprecated "https://github.com/tootsuite/mastodon/pull/11213"
479-
def card(
480-
%{assigns: %{user: user}, private: %{open_api_spex: %{params: %{id: status_id}}}} = conn,
481-
_
482-
) do
483-
with %Activity{} = activity <- Activity.get_by_id(status_id),
484-
true <- Visibility.visible_for_user?(activity, user),
485-
%Card{} = card_data <- Card.get_by_activity(activity) do
486-
render(conn, "card.json", card_data)
487-
else
488-
_ -> render_error(conn, :not_found, "Record not found")
489-
end
490-
end
491-
492475
@doc "GET /api/v1/statuses/:id/favourited_by"
493476
def favourited_by(
494477
%{assigns: %{user: user}, private: %{open_api_spex: %{params: %{id: id}}}} = conn,

lib/pleroma/web/router.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ defmodule Pleroma.Web.Router do
768768
get("/statuses", StatusController, :index)
769769
get("/statuses/:id", StatusController, :show)
770770
get("/statuses/:id/context", StatusController, :context)
771-
get("/statuses/:id/card", StatusController, :card)
772771
get("/statuses/:id/favourited_by", StatusController, :favourited_by)
773772
get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
774773
get("/statuses/:id/history", StatusController, :show_history)

test/pleroma/web/mastodon_api/controllers/status_controller_test.exs

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,63 +1643,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
16431643
end
16441644
end
16451645

1646-
describe "cards" do
1647-
setup do
1648-
Pleroma.StaticStubbedConfigMock
1649-
|> stub(:get, fn
1650-
[:rich_media, :enabled] -> true
1651-
path -> Pleroma.Test.StaticConfig.get(path)
1652-
end)
1653-
1654-
oauth_access(["read:statuses"])
1655-
end
1656-
1657-
test "returns rich-media card", %{conn: conn, user: user} do
1658-
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
1659-
1660-
{:ok, activity} = CommonAPI.post(user, %{status: "https://example.com/ogp"})
1661-
1662-
card_data = %{
1663-
"image" => "http://ia.media-imdb.com/images/rock.jpg",
1664-
"provider_name" => "example.com",
1665-
"provider_url" => "https://example.com",
1666-
"title" => "The Rock",
1667-
"type" => "link",
1668-
"url" => "https://example.com/ogp",
1669-
"description" =>
1670-
"Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer.",
1671-
"pleroma" => %{
1672-
"opengraph" => %{
1673-
"image" => "http://ia.media-imdb.com/images/rock.jpg",
1674-
"title" => "The Rock",
1675-
"type" => "video.movie",
1676-
"url" => "https://example.com/ogp",
1677-
"description" =>
1678-
"Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer."
1679-
}
1680-
}
1681-
}
1682-
1683-
response =
1684-
conn
1685-
|> get("/api/v1/statuses/#{activity.id}/card")
1686-
|> json_response_and_validate_schema(200)
1687-
1688-
assert response == card_data
1689-
1690-
# works with private posts
1691-
{:ok, activity} =
1692-
CommonAPI.post(user, %{status: "https://example.com/ogp", visibility: "direct"})
1693-
1694-
response_two =
1695-
conn
1696-
|> get("/api/v1/statuses/#{activity.id}/card")
1697-
|> json_response_and_validate_schema(200)
1698-
1699-
assert response_two == card_data
1700-
end
1701-
end
1702-
17031646
test "bookmarks" do
17041647
bookmarks_uri = "/api/v1/bookmarks"
17051648

0 commit comments

Comments
 (0)