mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-20 16:10:50 +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
|
@ -939,6 +939,20 @@ func GetUserByIDs(ctx context.Context, ids []int64) ([]*User, error) {
|
|||
return users, err
|
||||
}
|
||||
|
||||
func IsValidUserID(id int64) bool {
|
||||
return id > 0 || id == GhostUserID || id == ActionsUserID
|
||||
}
|
||||
|
||||
func GetUserFromMap(id int64, idMap map[int64]*User) (int64, *User) {
|
||||
if user, ok := idMap[id]; ok {
|
||||
return id, user
|
||||
}
|
||||
if id == ActionsUserID {
|
||||
return ActionsUserID, NewActionsUser()
|
||||
}
|
||||
return GhostUserID, NewGhostUser()
|
||||
}
|
||||
|
||||
// GetPossibleUserByID returns the user if id > 0 or return system usrs if id < 0
|
||||
func GetPossibleUserByID(ctx context.Context, id int64) (*User, error) {
|
||||
switch id {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue