From 44a670374224d277e7cf3d3b88c926e327773ba2 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 26 Nov 2019 13:14:52 -0500 Subject: [PATCH 1/2] Prevent failed requests on failed user silence check --- posts.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/posts.go b/posts.go index 6410735..189ea63 100644 --- a/posts.go +++ b/posts.go @@ -384,7 +384,6 @@ func handleViewPost(app *App, w http.ResponseWriter, r *http.Request) error { suspended, err := app.db.IsUserSuspended(ownerID.Int64) if err != nil { log.Error("view post: %v", err) - return ErrInternalGeneral } // Check if post has been unpublished @@ -511,7 +510,6 @@ func newPost(app *App, w http.ResponseWriter, r *http.Request) error { suspended, err := app.db.IsUserSuspended(userID) if err != nil { log.Error("new post: %v", err) - return ErrInternalGeneral } if suspended { return ErrUserSuspended @@ -685,7 +683,6 @@ func existingPost(app *App, w http.ResponseWriter, r *http.Request) error { suspended, err := app.db.IsUserSuspended(userID) if err != nil { log.Error("existing post: %v", err) - return ErrInternalGeneral } if suspended { return ErrUserSuspended @@ -888,7 +885,6 @@ func addPost(app *App, w http.ResponseWriter, r *http.Request) error { suspended, err := app.db.IsUserSuspended(ownerID) if err != nil { log.Error("add post: %v", err) - return ErrInternalGeneral } if suspended { return ErrUserSuspended @@ -991,7 +987,6 @@ func pinPost(app *App, w http.ResponseWriter, r *http.Request) error { suspended, err := app.db.IsUserSuspended(userID) if err != nil { log.Error("pin post: %v", err) - return ErrInternalGeneral } if suspended { return ErrUserSuspended @@ -1065,7 +1060,6 @@ func fetchPost(app *App, w http.ResponseWriter, r *http.Request) error { suspended, err := app.db.IsUserSuspended(ownerID) if err != nil { log.Error("fetch post: %v", err) - return ErrInternalGeneral } if suspended { @@ -1335,7 +1329,6 @@ func viewCollectionPost(app *App, w http.ResponseWriter, r *http.Request) error suspended, err := app.db.IsUserSuspended(c.OwnerID) if err != nil { log.Error("view collection post: %v", err) - return ErrInternalGeneral } // Check collection permissions From cfea887b78828d06f1a4b501f64d7ac7dcfbbd88 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 17 Dec 2019 20:58:32 -0500 Subject: [PATCH 2/2] Suppress "user not found" log when post not found This also saves a user suspension check when a post isn't found. --- posts.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/posts.go b/posts.go index 189ea63..4da09bc 100644 --- a/posts.go +++ b/posts.go @@ -381,9 +381,12 @@ func handleViewPost(app *App, w http.ResponseWriter, r *http.Request) error { } } - suspended, err := app.db.IsUserSuspended(ownerID.Int64) - if err != nil { - log.Error("view post: %v", err) + var suspended bool + if found { + suspended, err = app.db.IsUserSuspended(ownerID.Int64) + if err != nil { + log.Error("view post: %v", err) + } } // Check if post has been unpublished