feat(api): add the Mastodon quote entity to statuses
Mastodon 4.4+ clients read quotes from a top-level quote object with state and quoted_status; Pleroma only had pleroma.quote, so they did not show quote posts. Quoted statuses get a shallow quote with only quoted_status_id, as quotes are rendered one level deep. Inspired by Akkoma 5b7209980, which can not use the shallow form because Akkoma already had a top-level quote status.
This commit is contained in:
parent
ecd20c7587
commit
3890fbc127
4 changed files with 107 additions and 2 deletions
|
|
@ -345,7 +345,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
bookmark_folder: nil,
|
||||
list_id: nil
|
||||
},
|
||||
quotes_count: 0
|
||||
quotes_count: 0,
|
||||
quote: nil
|
||||
}
|
||||
|
||||
assert status == expected
|
||||
|
|
@ -507,6 +508,63 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
refute status.pleroma.quote_visible
|
||||
end
|
||||
|
||||
describe "Mastodon quote entity" do
|
||||
test "a quote has the quoted status, and quoted statuses only a shallow quote" do
|
||||
post = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, quote_post} = CommonAPI.post(user, %{status: "he", quoted_status_id: post.id})
|
||||
|
||||
{:ok, quoted_quote_post} =
|
||||
CommonAPI.post(user, %{status: "yo", quoted_status_id: quote_post.id})
|
||||
|
||||
status = StatusView.render("show.json", %{activity: quoted_quote_post})
|
||||
|
||||
assert %{state: "accepted", quoted_status: %{id: quoted_id} = quoted} = status.quote
|
||||
assert quoted_id == to_string(quote_post.id)
|
||||
assert quoted.quote == %{state: "accepted", quoted_status_id: to_string(post.id)}
|
||||
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "a quote of a post the user cannot see is unauthorized" do
|
||||
user = insert(:user)
|
||||
private = insert(:followers_only_note_activity, user: user)
|
||||
|
||||
quote_private =
|
||||
insert(:note_activity,
|
||||
note: insert(:note, data: %{"quoteUrl" => Object.normalize(private).data["id"]})
|
||||
)
|
||||
|
||||
status = StatusView.render("show.json", %{activity: quote_private})
|
||||
assert status.quote == %{state: "unauthorized", quoted_status: nil}
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
|
||||
follower = insert(:user)
|
||||
CommonAPI.follow(user, follower)
|
||||
|
||||
status = StatusView.render("show.json", %{activity: quote_private, for: follower})
|
||||
assert %{state: "accepted", quoted_status: %{id: id}} = status.quote
|
||||
assert id == to_string(private.id)
|
||||
end
|
||||
|
||||
test "a quote of a missing post is deleted" do
|
||||
quote_missing =
|
||||
insert(:note_activity,
|
||||
note: insert(:note, data: %{"quoteUrl" => "https://example.com/objects/gone"})
|
||||
)
|
||||
|
||||
status = StatusView.render("show.json", %{activity: quote_missing})
|
||||
assert status.quote == %{state: "deleted", quoted_status: nil}
|
||||
end
|
||||
|
||||
test "a post without a quote has no quote" do
|
||||
status = StatusView.render("show.json", %{activity: insert(:note_activity)})
|
||||
assert status.quote == nil
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
end
|
||||
|
||||
test "repost of quote post" do
|
||||
post = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue