Verified Commit 01175ef4 authored by Alex Gleason's avatar Alex Gleason Committed by Haelwenn
Browse files

Streamer: fix crash in MastodonAPI.StatusView

Backport of: !3508
parent 27e1e4c7
Pipeline #37123 passed with stages
in 83 minutes and 46 seconds
...@@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ...@@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies - Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies
- AdminAPI: Fix rendering reports containing a `nil` object - AdminAPI: Fix rendering reports containing a `nil` object
- Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error - Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error
- Mastodon API: Fix crash in Streamer related to reblogging
## 2.4.0 - 2021-08-08 ## 2.4.0 - 2021-08-08
......
...@@ -65,11 +65,19 @@ defp get_context_id(%{data: %{"context" => context}}) when is_binary(context), ...@@ -65,11 +65,19 @@ defp get_context_id(%{data: %{"context" => context}}) when is_binary(context),
defp get_context_id(_), do: nil defp get_context_id(_), do: nil
defp reblogged?(activity, user) do # Check if the user reblogged this status
object = Object.normalize(activity, fetch: false) || %{} defp reblogged?(activity, %User{ap_id: ap_id}) do
present?(user && user.ap_id in (object.data["announcements"] || [])) with %Object{data: %{"announcements" => announcements}} when is_list(announcements) <-
Object.normalize(activity, fetch: false) do
ap_id in announcements
else
_ -> false
end
end end
# False if the user is logged out
defp reblogged?(_activity, _user), do: false
def render("index.json", opts) do def render("index.json", opts) do
reading_user = opts[:for] reading_user = opts[:for]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment