Fix quote_visible attribute
This commit is contained in:
parent
a8b2f9205d
commit
08608afca5
@ -312,12 +312,16 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||
# Here the implicit index of the current content is 0
|
||||
chrono_order = history_len - 1
|
||||
|
||||
quote_id = get_quote_id(activity)
|
||||
|
||||
quote_activity = get_quote(activity, opts)
|
||||
|
||||
quote_id =
|
||||
case quote_activity do
|
||||
%Activity{id: id} -> id
|
||||
_ -> nil
|
||||
end
|
||||
|
||||
quote_post =
|
||||
if visible_for_user?(quote_activity, opts[:for]) do
|
||||
if visible_for_user?(quote_activity, opts[:for]) and opts[:show_quote] != false do
|
||||
quote_rendering_opts = Map.merge(opts, %{activity: quote_activity, show_quote: false})
|
||||
render("show.json", quote_rendering_opts)
|
||||
else
|
||||
@ -671,8 +675,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||
end
|
||||
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)
|
||||
|
||||
@ -692,13 +694,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||
end
|
||||
end
|
||||
|
||||
defp get_quote_id(activity) do
|
||||
case get_quote(activity, %{}) do
|
||||
%Activity{id: id} -> id
|
||||
_ -> nil
|
||||
end
|
||||
end
|
||||
|
||||
def render_content(%{data: %{"name" => name}} = object) when not is_nil(name) and name != "" do
|
||||
url = object.data["url"] || object.data["id"]
|
||||
|
||||
|
@ -438,11 +438,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
||||
assert status.pleroma.quote.id == to_string(quote_post.id)
|
||||
assert status.pleroma.quote_id == to_string(quote_post.id)
|
||||
assert status.pleroma.quote_url == Object.normalize(quote_post).data["id"]
|
||||
assert status.pleroma.quote_visible
|
||||
|
||||
# Quotes don't go more than one level deep
|
||||
refute status.pleroma.quote.pleroma.quote
|
||||
assert status.pleroma.quote.pleroma.quote_id == to_string(post.id)
|
||||
assert status.pleroma.quote.pleroma.quote_url == Object.normalize(post).data["id"]
|
||||
assert status.pleroma.quote.pleroma.quote_visible
|
||||
|
||||
# In an index
|
||||
[status] = StatusView.render("index.json", %{activities: [quoted_quote_post], as: :activity})
|
||||
|
Loading…
Reference in New Issue
Block a user