From 43bbc5478370cbfe3ab1eed730ea002ccec74708 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 10 Nov 2021 13:48:45 +0800 Subject: 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 Co-authored-by: Andrew Thornton Co-authored-by: wxiaoguang --- routers/api/v1/notify/repo.go | 2 +- routers/api/v1/notify/threads.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'routers') diff --git a/routers/api/v1/notify/repo.go b/routers/api/v1/notify/repo.go index 382d221b85..83d0fa5555 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 { + if err != nil && !models.IsErrCommentNotExist(err) { ctx.InternalServerError(err) return } diff --git a/routers/api/v1/notify/threads.go b/routers/api/v1/notify/threads.go index 2e241080b4..5bfdd4d963 100644 --- a/routers/api/v1/notify/threads.go +++ b/routers/api/v1/notify/threads.go @@ -40,7 +40,7 @@ func GetThread(ctx *context.APIContext) { if n == nil { return } - if err := n.LoadAttributes(); err != nil { + if err := n.LoadAttributes(); err != nil && !models.IsErrCommentNotExist(err) { ctx.InternalServerError(err) return } @@ -92,7 +92,7 @@ func ReadThread(ctx *context.APIContext) { ctx.InternalServerError(err) return } - if err = notif.LoadAttributes(); err != nil { + if err = notif.LoadAttributes(); err != nil && !models.IsErrCommentNotExist(err) { ctx.InternalServerError(err) return } -- cgit v1.2.3