From 5a3543dc9b4b315de758564200003f51b438b03f Mon Sep 17 00:00:00 2001 From: eladyn Date: Tue, 1 Mar 2022 14:13:12 +0100 Subject: [PATCH 1/3] ignore missing comment for user notifications --- routers/api/v1/notify/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/notify/user.go b/routers/api/v1/notify/user.go index 6e4c19d1bf2bb..035e0bbb0f110 100644 --- a/routers/api/v1/notify/user.go +++ b/routers/api/v1/notify/user.go @@ -81,7 +81,7 @@ func ListNotifications(ctx *context.APIContext) { return } err = nl.LoadAttributes() - if err != nil { + if err != nil && !models.IsErrCommentNotExist(err) { ctx.InternalServerError(err) return } From 1a1b57feb1550ca657b139aba8dd6bc4a6f455fa Mon Sep 17 00:00:00 2001 From: eladyn Date: Wed, 2 Mar 2022 02:18:58 +0100 Subject: [PATCH 2/3] instead fix bug in notifications model --- models/notification.go | 2 +- routers/api/v1/notify/repo.go | 2 +- routers/api/v1/notify/user.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/models/notification.go b/models/notification.go index 8f5d9d01e6e32..b195093f1584e 100644 --- a/models/notification.go +++ b/models/notification.go @@ -505,7 +505,7 @@ func (nl NotificationList) LoadAttributes() (err error) { return } } - return + return nil } func (nl NotificationList) getPendingRepoIDs() []int64 { diff --git a/routers/api/v1/notify/repo.go b/routers/api/v1/notify/repo.go index 8bf5d37116f92..30357ebd3f88d 100644 --- a/routers/api/v1/notify/repo.go +++ b/routers/api/v1/notify/repo.go @@ -121,7 +121,7 @@ func ListRepoNotifications(ctx *context.APIContext) { return } err = nl.LoadAttributes() - if err != nil && !models.IsErrCommentNotExist(err) { + if err != nil { ctx.InternalServerError(err) return } diff --git a/routers/api/v1/notify/user.go b/routers/api/v1/notify/user.go index 035e0bbb0f110..6e4c19d1bf2bb 100644 --- a/routers/api/v1/notify/user.go +++ b/routers/api/v1/notify/user.go @@ -81,7 +81,7 @@ func ListNotifications(ctx *context.APIContext) { return } err = nl.LoadAttributes() - if err != nil && !models.IsErrCommentNotExist(err) { + if err != nil { ctx.InternalServerError(err) return } From 0edc5f635175adaa02d39d30ffe0258a534673e2 Mon Sep 17 00:00:00 2001 From: eladyn Date: Wed, 2 Mar 2022 02:23:51 +0100 Subject: [PATCH 3/3] use local variable instead --- models/notification.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/notification.go b/models/notification.go index b195093f1584e..b53d236e433f9 100644 --- a/models/notification.go +++ b/models/notification.go @@ -498,11 +498,12 @@ func (n *Notification) APIURL() string { type NotificationList []*Notification // LoadAttributes load Repo Issue User and Comment if not loaded -func (nl NotificationList) LoadAttributes() (err error) { +func (nl NotificationList) LoadAttributes() error { + var err error for i := 0; i < len(nl); i++ { err = nl[i].LoadAttributes() if err != nil && !IsErrCommentNotExist(err) { - return + return err } } return nil