StatusView: add `quote_visible` param

This commit is contained in:
Alex Gleason 2022-01-26 11:52:50 -06:00 committed by tusooa
parent 6f11f11519
commit 74e0a4555f
No known key found for this signature in database
GPG Key ID: 42AEC43D48433C51
3 changed files with 9 additions and 0 deletions

View File

@ -204,6 +204,10 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
nullable: true,
description: "URL of the quoted status"
},
quote_visible: %Schema{
type: :boolean,
description: "`true` if the quoted post is visible to the user"
},
local: %Schema{
type: :boolean,
description: "`true` if the post was made on the local instance"

View File

@ -432,6 +432,7 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
in_reply_to_account_acct: reply_to_user && reply_to_user.nickname,
quote: quote_post,
quote_url: object.data["quoteUrl"],
quote_visible: visible_for_user?(quote_activity, opts[:for]),
content: %{"text/plain" => content_plaintext},
spoiler_text: %{"text/plain" => summary},
expires_at: expires_at,

View File

@ -328,6 +328,7 @@ test "a note activity" do
in_reply_to_account_acct: nil,
quote: nil,
quote_url: nil,
quote_visible: false,
content: %{"text/plain" => HTML.strip_tags(object_data["content"])},
spoiler_text: %{"text/plain" => HTML.strip_tags(object_data["summary"])},
expires_at: nil,
@ -462,6 +463,7 @@ test "quoted private post" do
# The quote isn't rendered
refute status.pleroma.quote
assert status.pleroma.quote_url == private_object.data["id"]
refute status.pleroma.quote_visible
# After following the user, the quote is rendered
follower = insert(:user)
@ -469,6 +471,7 @@ test "quoted private post" do
status = StatusView.render("show.json", %{activity: quote_private, for: follower})
assert status.pleroma.quote.id == to_string(private.id)
assert status.pleroma.quote_visible
end
test "quoted direct message" do
@ -485,6 +488,7 @@ test "quoted direct message" do
# The quote isn't rendered
refute status.pleroma.quote
assert status.pleroma.quote_url == direct_object.data["id"]
refute status.pleroma.quote_visible
end
test "contains mentions" do