Skip to content

Commit 37061e8

Browse files
authored
Use ghost user if user was not found (#29161)
Fixes #29159
1 parent 4feb91f commit 37061e8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

models/issues/comment_list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ func (comments CommentList) loadAssignees(ctx context.Context) error {
225225

226226
for _, comment := range comments {
227227
comment.Assignee = assignees[comment.AssigneeID]
228+
if comment.Assignee == nil {
229+
comment.AssigneeID = user_model.GhostUserID
230+
comment.Assignee = user_model.NewGhostUser()
231+
}
228232
}
229233
return nil
230234
}

models/issues/review.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ func (r *Review) LoadReviewer(ctx context.Context) (err error) {
159159
return err
160160
}
161161
r.Reviewer, err = user_model.GetPossibleUserByID(ctx, r.ReviewerID)
162+
if err != nil {
163+
if !user_model.IsErrUserNotExist(err) {
164+
return fmt.Errorf("GetPossibleUserByID [%d]: %w", r.ReviewerID, err)
165+
}
166+
r.ReviewerID = user_model.GhostUserID
167+
r.Reviewer = user_model.NewGhostUser()
168+
return nil
169+
}
162170
return err
163171
}
164172

0 commit comments

Comments
 (0)