diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-10 13:48:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-10 13:48:45 +0800 |
commit | 43bbc5478370cbfe3ab1eed730ea002ccec74708 (patch) | |
tree | a61e1a93843b727c40ef49b68ec75898a72e78e4 /models | |
parent | 33fca2b537d36cf998dd27425b2bb8ed5b0965f3 (diff) | |
download | gitea-43bbc5478370cbfe3ab1eed730ea002ccec74708.tar.gz gitea-43bbc5478370cbfe3ab1eed730ea002ccec74708.zip |
Fix 500 when a comment was deleted which has a notification (#17550)
* Fix 500 when a comment was deleted which has a notification
* Tolerate missing Comment in other places too
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models')
-rw-r--r-- | models/notification.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/models/notification.go b/models/notification.go index ce656f4355..48249ae84c 100644 --- a/models/notification.go +++ b/models/notification.go @@ -434,7 +434,13 @@ func (n *Notification) loadComment(e db.Engine) (err error) { if n.Comment == nil && n.CommentID != 0 { n.Comment, err = getCommentByID(e, n.CommentID) if err != nil { - return fmt.Errorf("GetCommentByID [%d] for issue ID [%d]: %v", n.CommentID, n.IssueID, err) + if IsErrCommentNotExist(err) { + return ErrCommentNotExist{ + ID: n.CommentID, + IssueID: n.IssueID, + } + } + return err } } return nil @@ -488,7 +494,7 @@ type NotificationList []*Notification func (nl NotificationList) LoadAttributes() (err error) { for i := 0; i < len(nl); i++ { err = nl[i].LoadAttributes() - if err != nil { + if err != nil && !IsErrCommentNotExist(err) { return } } |