diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-08-13 10:25:42 -0500 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2021-08-13 17:58:03 +0200 |
commit | 01175ef4988e98aa38851e77703ffc60a3756fdd (patch) | |
tree | b61ce3616affdc025b8b5a6fcf9f033b9b53fe41 /lib | |
parent | 27e1e4c742bb37a89e0ca91fda03b5ca8be3984a (diff) | |
download | pleroma-01175ef4988e98aa38851e77703ffc60a3756fdd.tar.gz |
Streamer: fix crash in MastodonAPI.StatusView
Backport of: https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3508
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index da44e0a74..463f34198 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -65,11 +65,19 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do defp get_context_id(_), do: nil - defp reblogged?(activity, user) do - object = Object.normalize(activity, fetch: false) || %{} - present?(user && user.ap_id in (object.data["announcements"] || [])) + # Check if the user reblogged this status + defp reblogged?(activity, %User{ap_id: ap_id}) do + with %Object{data: %{"announcements" => announcements}} when is_list(announcements) <- + Object.normalize(activity, fetch: false) do + ap_id in announcements + else + _ -> false + end end + # False if the user is logged out + defp reblogged?(_activity, _user), do: false + def render("index.json", opts) do reading_user = opts[:for] |