lib/pleroma/web/mastodon_api/mastodon_api_controller.ex: Output an error when render...
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Thu, 30 Aug 2018 12:49:42 +0000 (14:49 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Thu, 25 Oct 2018 03:24:03 +0000 (05:24 +0200)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index cbda069df9c1c02fc46273aaa06465d07373ca15..281f2a137a4dae4e97648cdf20d232915f0fa5e9 100644 (file)
@@ -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