|
|
@@ -649,53 +649,41 @@ func (repo *Repository) GetAssignees() (_ []*User, err error) { |
|
|
|
return repo.getAssignees(x) |
|
|
|
} |
|
|
|
|
|
|
|
func (repo *Repository) getReviewersPrivate(e Engine, doerID, posterID int64) (users []*User, err error) { |
|
|
|
users = make([]*User, 0, 20) |
|
|
|
|
|
|
|
if err = e. |
|
|
|
SQL("SELECT * FROM `user` WHERE id in (SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? "+ |
|
|
|
" UNION SELECT owner_id FROM `repository` WHERE id = ?) AND id NOT IN ( ?, ?) ORDER BY name", |
|
|
|
repo.ID, AccessModeWrite, repo.ID, |
|
|
|
doerID, posterID). |
|
|
|
Find(&users); err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
return users, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (repo *Repository) getReviewersPublic(e Engine, doerID, posterID int64) (_ []*User, err error) { |
|
|
|
|
|
|
|
users := make([]*User, 0) |
|
|
|
|
|
|
|
const SQLCmd = "SELECT * FROM `user` WHERE id IN ( " + |
|
|
|
"SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? " + |
|
|
|
" UNION" + |
|
|
|
" SELECT owner_id FROM `repository` WHERE id = ?)" + |
|
|
|
" AND id NOT IN ( ?, ?) ORDER BY name " |
|
|
|
|
|
|
|
if err = e. |
|
|
|
SQL(SQLCmd, |
|
|
|
repo.ID, AccessModeWrite, repo.ID, doerID, posterID). |
|
|
|
Find(&users); err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
return users, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (repo *Repository) getReviewers(e Engine, doerID, posterID int64) (users []*User, err error) { |
|
|
|
if err = repo.getOwner(e); err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
if repo.IsPrivate || |
|
|
|
(repo.Owner.IsOrganization() && repo.Owner.Visibility == api.VisibleTypePrivate) { |
|
|
|
users, err = repo.getReviewersPrivate(x, doerID, posterID) |
|
|
|
if repo.Owner.IsOrganization() { |
|
|
|
const SQLCmd = "SELECT * FROM `user` WHERE id IN (" + |
|
|
|
"SELECT DISTINCT(t3.user_id) FROM ( " + |
|
|
|
"SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ?" + |
|
|
|
"UNION select t2.uid as user_id from team t1 left join team_user t2 on t1.id = t2.team_id where t1.org_id = ? and t1.authorize = 4) t3)" + |
|
|
|
" AND id NOT IN ( ?, ?) ORDER BY name " |
|
|
|
|
|
|
|
if err = e. |
|
|
|
SQL(SQLCmd, |
|
|
|
repo.ID, AccessModeWrite, repo.ID, doerID, posterID). |
|
|
|
Find(&users); err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} else { |
|
|
|
users, err = repo.getReviewersPublic(x, doerID, posterID) |
|
|
|
const SQLCmd = "SELECT * FROM `user` WHERE id IN ( " + |
|
|
|
"SELECT DISTINCT(t3.user_id) FROM ( " + |
|
|
|
"SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? " + |
|
|
|
" UNION" + |
|
|
|
" SELECT owner_id as user_id FROM `repository` WHERE id = ?) t3)" + |
|
|
|
" AND id NOT IN ( ?, ?) ORDER BY name " |
|
|
|
|
|
|
|
if err = e. |
|
|
|
SQL(SQLCmd, |
|
|
|
repo.ID, AccessModeWrite, repo.ID, doerID, posterID). |
|
|
|
Find(&users); err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
|
|
|
|
return users, nil |
|
|
|
} |
|
|
|
|
|
|
|
// GetReviewers get all users can be requested to review |
|
|
|