diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2018-08-30 14:49:42 +0200 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2018-10-25 05:24:03 +0200 |
commit | 2da0ffeb286b58c62dd005db55e7d089a02380ed (patch) | |
tree | 15223bb3e504f3fc0f1a6e0e7aadff03c032fa75 | |
parent | 0c10be87311cbe851c48218899f305e81e880741 (diff) | |
download | pleroma-2da0ffeb286b58c62dd005db55e7d089a02380ed.tar.gz |
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex: Output an error when render(status.json) gives a nil
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index cbda069df..281f2a137 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -282,7 +282,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController 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 |