1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-12-25 04:53:06 +00:00

Streamer: fix crash in MastodonAPI.StatusView

This commit is contained in:
Alex Gleason 2021-08-13 10:25:42 -05:00
parent dc63aaf84f
commit b7bbf42acd
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -65,10 +65,18 @@ defp get_context_id(%{data: %{"context" => context}}) when is_binary(context),
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]