summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortusooa <tusooa@kazv.moe>2023-07-12 23:56:54 -0400
committertusooa <tusooa@kazv.moe>2023-09-13 19:20:33 -0400
commit08608afca5566f712acdc14b7c43976d6d071106 (patch)
tree42f8d025607f9602f1a81a67f506ade936c9b684
parenta8b2f9205d16465a3b11d3802c966db3da908c5d (diff)
Fix quote_visible attribute
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex19
-rw-r--r--test/pleroma/web/mastodon_api/views/status_view_test.exs2
2 files changed, 9 insertions, 12 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 3d3039751..d070262cc 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -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"]
diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs
index 221244d4e..baa9b32f5 100644
--- a/test/pleroma/web/mastodon_api/views/status_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs
@@ -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})