mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 04:12:10 +00:00
fix: never set Poster or Assignee to nil
When a user is not found for whatever reason, it must be mapped to the GhostUser. Fixes: https://codeberg.org/forgejo/forgejo/issues/4718
This commit is contained in:
parent
5bbc9ef97c
commit
e6786db393
6 changed files with 188 additions and 24 deletions
|
@ -79,7 +79,7 @@ func (issues IssueList) LoadPosters(ctx context.Context) error {
|
|||
}
|
||||
|
||||
posterIDs := container.FilterSlice(issues, func(issue *Issue) (int64, bool) {
|
||||
return issue.PosterID, issue.Poster == nil && issue.PosterID > 0
|
||||
return issue.PosterID, issue.Poster == nil && user_model.IsValidUserID(issue.PosterID)
|
||||
})
|
||||
|
||||
posterMaps, err := getPostersByIDs(ctx, posterIDs)
|
||||
|
@ -89,7 +89,7 @@ func (issues IssueList) LoadPosters(ctx context.Context) error {
|
|||
|
||||
for _, issue := range issues {
|
||||
if issue.Poster == nil {
|
||||
issue.Poster = getPoster(issue.PosterID, posterMaps)
|
||||
issue.PosterID, issue.Poster = user_model.GetUserFromMap(issue.PosterID, posterMaps)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -115,20 +115,6 @@ func getPostersByIDs(ctx context.Context, posterIDs []int64) (map[int64]*user_mo
|
|||
return posterMaps, nil
|
||||
}
|
||||
|
||||
func getPoster(posterID int64, posterMaps map[int64]*user_model.User) *user_model.User {
|
||||
if posterID == user_model.ActionsUserID {
|
||||
return user_model.NewActionsUser()
|
||||
}
|
||||
if posterID <= 0 {
|
||||
return nil
|
||||
}
|
||||
poster, ok := posterMaps[posterID]
|
||||
if !ok {
|
||||
return user_model.NewGhostUser()
|
||||
}
|
||||
return poster
|
||||
}
|
||||
|
||||
func (issues IssueList) getIssueIDs() []int64 {
|
||||
ids := make([]int64, 0, len(issues))
|
||||
for _, issue := range issues {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue