Skip to content

Commit 77db40e

Browse files
GiteaBotZettat123
andauthored
Fix bugs related to notification endpoints (#25548) (#25562)
Backport #25548 by @Zettat123 This PR - fixes #25545 - fixes two incorrect `reqToken()` in `/notifications` endpoints (caused by #24767) Co-authored-by: Zettat123 <zettat123@gmail.com>
1 parent 7222bac commit 77db40e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

routers/api/v1/api.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,11 @@ func Routes(ctx gocontext.Context) *web.Route {
783783
m.Group("/notifications", func() {
784784
m.Combo("").
785785
Get(notify.ListNotifications).
786-
Put(notify.ReadNotifications, reqToken())
786+
Put(reqToken(), notify.ReadNotifications)
787787
m.Get("/new", notify.NewAvailable)
788788
m.Combo("/threads/{id}").
789789
Get(notify.GetThread).
790-
Patch(notify.ReadThread, reqToken())
790+
Patch(reqToken(), notify.ReadThread)
791791
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryNotification))
792792

793793
// Users (requires user scope)

routers/api/v1/notify/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
183183
if len(qLastRead) > 0 {
184184
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
185185
if err != nil {
186-
ctx.InternalServerError(err)
186+
ctx.Error(http.StatusBadRequest, "Parse", err)
187187
return
188188
}
189189
if !tmpLastRead.IsZero() {

routers/api/v1/notify/user.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func ReadNotifications(ctx *context.APIContext) {
132132
if len(qLastRead) > 0 {
133133
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
134134
if err != nil {
135-
ctx.InternalServerError(err)
135+
ctx.Error(http.StatusBadRequest, "Parse", err)
136136
return
137137
}
138138
if !tmpLastRead.IsZero() {

0 commit comments

Comments
 (0)