From 11714fbaa2b90e1fc577d2b9b3d4075a44181633 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 3 Aug 2017 17:46:01 +0200 Subject: [PATCH] Better error handling for user feeds. --- lib/pleroma/web/ostatus/ostatus_controller.ex | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 05acfd04b..a2c2a4b4c 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -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 -- 2.45.2