mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-29 21:41:02 +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
(cherry picked from commit e6786db393)
	
	
This commit is contained in:
		
					parent
					
						
							
								d09d633c9c
							
						
					
				
			
			
				commit
				
					
						0f853d1a93
					
				
			
		
					 6 changed files with 188 additions and 24 deletions
				
			
		|  | @ -906,6 +906,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