From 867eb53b3596bd7b3f2be3c53a3faf857f4cd36d Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sat, 8 Feb 2020 12:55:10 -0500 Subject: [PATCH] Show 404 when remote user not found This notifies the user that the remote user doesn't exist, instead of showing a blank page. Ref T627 --- collections.go | 6 +++--- errors.go | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/collections.go b/collections.go index 8ee88f1..189b4e4 100644 --- a/collections.go +++ b/collections.go @@ -862,9 +862,9 @@ func handleViewMention(app *App, w http.ResponseWriter, r *http.Request) error { handle := vars["handle"] remoteUser, err := app.db.GetProfilePageFromHandle(app, handle) - if err != nil { - log.Error("Couldn't find this user "+handle, err) - return nil + if err != nil || remoteUser == "" { + log.Error("Couldn't find user %s: %v", handle, err) + return ErrRemoteUserNotFound } return impart.HTTPError{Status: http.StatusFound, Message: remoteUser} diff --git a/errors.go b/errors.go index c0d435c..1da713a 100644 --- a/errors.go +++ b/errors.go @@ -1,5 +1,5 @@ /* - * Copyright © 2018 A Bunch Tell LLC. + * Copyright © 2018-2020 A Bunch Tell LLC. * * This file is part of WriteFreely. * @@ -45,8 +45,9 @@ var ( ErrPostUnpublished = impart.HTTPError{Status: http.StatusGone, Message: "Post unpublished by author."} ErrPostFetchError = impart.HTTPError{Status: http.StatusInternalServerError, Message: "We encountered an error getting the post. The humans have been alerted."} - ErrUserNotFound = impart.HTTPError{http.StatusNotFound, "User doesn't exist."} - ErrUserNotFoundEmail = impart.HTTPError{http.StatusNotFound, "Please enter your username instead of your email address."} + ErrUserNotFound = impart.HTTPError{http.StatusNotFound, "User doesn't exist."} + ErrRemoteUserNotFound = impart.HTTPError{http.StatusNotFound, "Remote user not found."} + ErrUserNotFoundEmail = impart.HTTPError{http.StatusNotFound, "Please enter your username instead of your email address."} ErrUserSuspended = impart.HTTPError{http.StatusForbidden, "Account is silenced."} )