mirror of
https://git.pleroma.social/sjw/pleroma.git
synced 2024-12-27 14:25:17 +01:00
Add fallback value to the admin report view.
This is to avoid 500 error when the reported user no longer exists in the database.
This commit is contained in:
parent
79c88a257f
commit
ab50c6b3ca
@ -46,8 +46,10 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp merge_account_views(user) do
|
defp merge_account_views(%User{} = user) do
|
||||||
Pleroma.Web.MastodonAPI.AccountView.render("account.json", %{user: user})
|
Pleroma.Web.MastodonAPI.AccountView.render("account.json", %{user: user})
|
||||||
|> Map.merge(Pleroma.Web.AdminAPI.AccountView.render("show.json", %{user: user}))
|
|> Map.merge(Pleroma.Web.AdminAPI.AccountView.render("show.json", %{user: user}))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp merge_account_views(_), do: %{}
|
||||||
end
|
end
|
||||||
|
@ -111,4 +111,20 @@ defmodule Pleroma.Web.AdminAPI.ReportViewTest do
|
|||||||
refute "<script> alert('hecked :D:D:D:D:D:D:D') </script>" ==
|
refute "<script> alert('hecked :D:D:D:D:D:D:D') </script>" ==
|
||||||
ReportView.render("show.json", %{report: activity})[:content]
|
ReportView.render("show.json", %{report: activity})[:content]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "doesn't error out when the user doesn't exists" do
|
||||||
|
user = insert(:user)
|
||||||
|
other_user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, activity} =
|
||||||
|
CommonAPI.report(user, %{
|
||||||
|
"account_id" => other_user.id,
|
||||||
|
"comment" => ""
|
||||||
|
})
|
||||||
|
|
||||||
|
Pleroma.User.delete(other_user)
|
||||||
|
Pleroma.User.invalidate_cache(other_user)
|
||||||
|
|
||||||
|
assert %{} = ReportView.render("show.json", %{report: activity})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user