From 0664387694732b322718a214ec7c9023c114c29c Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Wed, 28 Jun 2023 11:32:32 +0800 Subject: [PATCH 1/2] fix reqToken --- routers/api/v1/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index be66cc5240812..8b7f55976b0ec 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -777,11 +777,11 @@ func Routes() *web.Route { m.Group("/notifications", func() { m.Combo(""). Get(notify.ListNotifications). - Put(notify.ReadNotifications, reqToken()) + Put(reqToken(), notify.ReadNotifications) m.Get("/new", notify.NewAvailable) m.Combo("/threads/{id}"). Get(notify.GetThread). - Patch(notify.ReadThread, reqToken()) + Patch(reqToken(), notify.ReadThread) }, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryNotification)) // Users (requires user scope) From b97af3ab0fdc20f30eceee2fc86b1b16774575d0 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Wed, 28 Jun 2023 11:33:45 +0800 Subject: [PATCH 2/2] return 400 instead of 500 --- routers/api/v1/notify/repo.go | 2 +- routers/api/v1/notify/user.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/notify/repo.go b/routers/api/v1/notify/repo.go index bd3b86a6f1525..e16c54a2c0bb4 100644 --- a/routers/api/v1/notify/repo.go +++ b/routers/api/v1/notify/repo.go @@ -183,7 +183,7 @@ func ReadRepoNotifications(ctx *context.APIContext) { if len(qLastRead) > 0 { tmpLastRead, err := time.Parse(time.RFC3339, qLastRead) if err != nil { - ctx.InternalServerError(err) + ctx.Error(http.StatusBadRequest, "Parse", err) return } if !tmpLastRead.IsZero() { diff --git a/routers/api/v1/notify/user.go b/routers/api/v1/notify/user.go index 2261610c09238..a9c6b4361794d 100644 --- a/routers/api/v1/notify/user.go +++ b/routers/api/v1/notify/user.go @@ -132,7 +132,7 @@ func ReadNotifications(ctx *context.APIContext) { if len(qLastRead) > 0 { tmpLastRead, err := time.Parse(time.RFC3339, qLastRead) if err != nil { - ctx.InternalServerError(err) + ctx.Error(http.StatusBadRequest, "Parse", err) return } if !tmpLastRead.IsZero() {