From aced7547c2fa88a2a626f2b0169741905e8b6dc8 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Wed, 14 Feb 2024 18:51:51 +0100 Subject: [PATCH] Use ghost user if user was not found (#29161) (#29169) Backport #29161 (cherry picked from commit d823465d94b3b43945eace060000db9334eca52d) --- models/issues/comment_list.go | 4 ++++ models/issues/review.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/models/issues/comment_list.go b/models/issues/comment_list.go index cb7df3270d..30a437ea50 100644 --- a/models/issues/comment_list.go +++ b/models/issues/comment_list.go @@ -225,6 +225,10 @@ func (comments CommentList) loadAssignees(ctx context.Context) error { for _, comment := range comments { comment.Assignee = assignees[comment.AssigneeID] + if comment.Assignee == nil { + comment.AssigneeID = user_model.GhostUserID + comment.Assignee = user_model.NewGhostUser() + } } return nil } diff --git a/models/issues/review.go b/models/issues/review.go index 5bfb8b9dd2..3fca30d7b6 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -159,6 +159,14 @@ func (r *Review) LoadReviewer(ctx context.Context) (err error) { return err } r.Reviewer, err = user_model.GetPossibleUserByID(ctx, r.ReviewerID) + if err != nil { + if !user_model.IsErrUserNotExist(err) { + return fmt.Errorf("GetPossibleUserByID [%d]: %w", r.ReviewerID, err) + } + r.ReviewerID = user_model.GhostUserID + r.Reviewer = user_model.NewGhostUser() + return nil + } return err }