Add fallback for reports that don't have attached activities

This commit is contained in:
FloatingGhost 2022-11-08 11:01:47 +00:00
parent a0b8e3c842
commit 479aacb1b6
2 changed files with 184 additions and 182 deletions

View file

@ -209,8 +209,7 @@ def render(
end end
def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
object = Object.normalize(activity, fetch: false) with %Object{} = object <- Object.normalize(activity, fetch: false) do
user = CommonAPI.get_user(activity.data["actor"]) user = CommonAPI.get_user(activity.data["actor"])
user_follower_address = user.follower_address user_follower_address = user.follower_address
@ -415,6 +414,9 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
source: object.data["source"] source: object.data["source"]
} }
} }
else
nil -> nil
end
end end
def render("show.json", _) do def render("show.json", _) do

View file

@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.ReportViewTest do defmodule Pleroma.Web.AdminAPI.ReportViewTest do
use Pleroma.DataCase, async: true use Pleroma.DataCase, async: false
import Pleroma.Factory import Pleroma.Factory