Better error handling for ActivityPubController
[akkoma] / lib / pleroma / web / activity_pub / activity_pub_controller.ex
index a6a9b99eff30604563d37981f5114318a2a1bd8c..ee5d319a716b76553fb55dcc8ee0512b3b08cd43 100644 (file)
@@ -27,9 +27,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
       |> json(ObjectView.render("object.json", %{object: object}))
     else
       {:public?, false} ->
-        conn
-        |> put_status(404)
-        |> json("Not found")
+        {:error, :not_found}
     end
   end
 
@@ -107,6 +105,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
     json(conn, "ok")
   end
 
+  def errors(conn, {:error, :not_found}) do
+    conn
+    |> put_status(404)
+    |> json("Not found")
+  end
+
   def errors(conn, _e) do
     conn
     |> put_status(500)