Better error handling for user feeds.
authorRoger Braun <roger@rogerbraun.net>
Thu, 3 Aug 2017 15:46:01 +0000 (17:46 +0200)
committerRoger Braun <roger@rogerbraun.net>
Thu, 3 Aug 2017 15:46:01 +0000 (17:46 +0200)
lib/pleroma/web/ostatus/ostatus_controller.ex

index 05acfd04bc0f3d5879b4a4c4e3b9d185e8676339..a2c2a4b4ca3f8b45bf67cef9884b404a1b4e4eb2 100644 (file)
@@ -8,11 +8,13 @@ defmodule Pleroma.Web.OStatus.OStatusController do
   import Ecto.Query
 
   def feed_redirect(conn, %{"nickname" => nickname}) do
-    user = User.get_cached_by_nickname(nickname)
-
-    case get_format(conn) do
-      "html" -> Fallback.RedirectController.redirector(conn, nil)
-      _ -> redirect conn, external: OStatus.feed_path(user)
+    with %User{} = user <- User.get_cached_by_nickname(nickname) do
+      case get_format(conn) do
+        "html" -> Fallback.RedirectController.redirector(conn, nil)
+        _ -> redirect conn, external: OStatus.feed_path(user)
+      end
+    else
+      _e -> send_resp(conn, 404, "No user found")
     end
   end