StatusView: return quote post inside a reblog

This commit is contained in:
Alex Gleason 2022-01-28 12:33:07 -06:00 committed by tusooa
parent 93e4972b50
commit cf8e425883
No known key found for this signature in database
GPG Key ID: 42AEC43D48433C51
2 changed files with 18 additions and 4 deletions

View File

@ -668,13 +668,15 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
end
end
def get_quote(_activity, %{show_quote: false}) do
nil
end
def get_quote(_activity, %{show_quote: false}), do: nil
def get_quote(activity, %{quoted_activities: quoted_activities}) do
object = Object.normalize(activity, fetch: false)
quoted_activities[object.data["quoteUrl"]]
with nil <- quoted_activities[object.data["quoteUrl"]] do
# For when a quote post is inside an Announce
Activity.get_create_by_object_ap_id_with_object(object.data["quoteUrl"])
end
end
def get_quote(%{data: %{"object" => _object}} = activity, _) do

View File

@ -491,6 +491,18 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
refute status.pleroma.quote_visible
end
test "repost of quote post" do
post = insert(:note_activity)
user = insert(:user)
{:ok, quote_post} = CommonAPI.post(user, %{status: "he", quote_id: post.id})
{:ok, repost} = CommonAPI.repeat(quote_post.id, user)
[status] = StatusView.render("index.json", %{activities: [repost], as: :activity})
assert status.reblog.pleroma.quote.id == to_string(post.id)
end
test "contains mentions" do
user = insert(:user)
mentioned = insert(:user)