1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-03 00:45:22 +02:00

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>
This commit is contained in:
Lunny Xiao 2021-11-10 13:48:45 +08:00 committed by GitHub
parent 33fca2b537
commit 43bbc54783
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View file

@ -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
}
}