lib/pleroma/web/mastodon_api/mastodon_api_controller.ex: Output an error when render(status.json) gives a nil

This commit is contained in:
Haelwenn (lanodan) Monnier 2018-08-30 14:49:42 +02:00
parent 0c10be8731
commit 2da0ffeb28
No known key found for this signature in database
GPG Key ID: D5B7A8E43C997DEE
1 changed files with 9 additions and 1 deletions

View File

@ -282,7 +282,15 @@ def dm_timeline(%{assigns: %{user: user}} = conn, _params) do
def get_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do
with %Activity{} = activity <- Repo.get(Activity, id),
true <- ActivityPub.visible_for_user?(activity, user) do
render(conn, StatusView, "status.json", %{activity: activity, for: user})
res = render(conn, StatusView, "status.json", %{activity: activity, for: user})
if res == nil do
conn
|> put_status(501)
|> json(%{error: "Can't display this status"})
else
res
end
end
end