mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	hide issues from org private repos w/o team assignment (#4034)
This commit is contained in:
		
				
					committed by
					
						 techknowlogick
						techknowlogick
					
				
			
			
				
	
			
			
			
						parent
						
							46d19c4676
						
					
				
				
					commit
					0b3ea42847
				
			| @@ -546,28 +546,46 @@ func (u *User) GetRepositories(page, pageSize int) (err error) { | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // GetRepositoryIDs returns repositories IDs where user owned | ||||
| func (u *User) GetRepositoryIDs() ([]int64, error) { | ||||
| // GetRepositoryIDs returns repositories IDs where user owned and has unittypes | ||||
| func (u *User) GetRepositoryIDs(units ...UnitType) ([]int64, error) { | ||||
| 	var ids []int64 | ||||
| 	return ids, x.Table("repository").Cols("id").Where("owner_id = ?", u.ID).Find(&ids) | ||||
|  | ||||
| 	sess := x.Table("repository").Cols("repository.id") | ||||
|  | ||||
| 	if len(units) > 0 { | ||||
| 		sess = sess.Join("INNER", "repo_unit", "repository.id = repo_unit.repo_id") | ||||
| 		sess = sess.In("repo_unit.type", units) | ||||
| 	} | ||||
|  | ||||
| 	return ids, sess.Where("owner_id = ?", u.ID).Find(&ids) | ||||
| } | ||||
|  | ||||
| // GetOrgRepositoryIDs returns repositories IDs where user's team owned | ||||
| func (u *User) GetOrgRepositoryIDs() ([]int64, error) { | ||||
| // GetOrgRepositoryIDs returns repositories IDs where user's team owned and has unittypes | ||||
| func (u *User) GetOrgRepositoryIDs(units ...UnitType) ([]int64, error) { | ||||
| 	var ids []int64 | ||||
| 	return ids, x.Table("repository"). | ||||
|  | ||||
| 	sess := x.Table("repository"). | ||||
| 		Cols("repository.id"). | ||||
| 		Join("INNER", "team_user", "repository.owner_id = team_user.org_id AND team_user.uid = ?", u.ID). | ||||
| 		Join("INNER", "team_user", "repository.owner_id = team_user.org_id"). | ||||
| 		Join("INNER", "team_repo", "repository.is_private != ? OR (team_user.team_id = team_repo.team_id AND repository.id = team_repo.repo_id)", true) | ||||
|  | ||||
| 	if len(units) > 0 { | ||||
| 		sess = sess.Join("INNER", "team_unit", "team_unit.team_id = team_user.team_id") | ||||
| 		sess = sess.In("team_unit.type", units) | ||||
| 	} | ||||
|  | ||||
| 	return ids, sess. | ||||
| 		Where("team_user.uid = ?", u.ID). | ||||
| 		GroupBy("repository.id").Find(&ids) | ||||
| } | ||||
|  | ||||
| // GetAccessRepoIDs returns all repositories IDs where user's or user is a team member organizations | ||||
| func (u *User) GetAccessRepoIDs() ([]int64, error) { | ||||
| 	ids, err := u.GetRepositoryIDs() | ||||
| func (u *User) GetAccessRepoIDs(units ...UnitType) ([]int64, error) { | ||||
| 	ids, err := u.GetRepositoryIDs(units...) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	ids2, err := u.GetOrgRepositoryIDs() | ||||
| 	ids2, err := u.GetOrgRepositoryIDs(units...) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user