Skip to content

Commit

Permalink
Use ghost user if user was not found (go-gitea#29161)
Browse files Browse the repository at this point in the history
  • Loading branch information
KN4CK3R committed Feb 14, 2024
1 parent dd8bc1d commit 9eb3945
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions models/issues/comment_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions models/issues/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 9eb3945

Please sign in to comment.