Allow poster to choose reviewers (#21084)

Allow the poster of a PR to choose reviewers (add only). 

Solve #20746
tokarchuk/v1.18
Jason Song 2 years ago committed by GitHub
parent b5d21c0adf
commit 831e981357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      routers/web/repo/issue.go
  2. 5
      services/issue/assignee.go

@ -1336,13 +1336,18 @@ func ViewIssue(ctx *context.Context) {
if issue.IsPull { if issue.IsPull {
canChooseReviewer := ctx.Repo.CanWrite(unit.TypePullRequests) canChooseReviewer := ctx.Repo.CanWrite(unit.TypePullRequests)
if !canChooseReviewer && ctx.Doer != nil && ctx.IsSigned { if ctx.Doer != nil && ctx.IsSigned {
if !canChooseReviewer {
canChooseReviewer = ctx.Doer.ID == issue.PosterID
}
if !canChooseReviewer {
canChooseReviewer, err = issues_model.IsOfficialReviewer(ctx, issue, ctx.Doer) canChooseReviewer, err = issues_model.IsOfficialReviewer(ctx, issue, ctx.Doer)
if err != nil { if err != nil {
ctx.ServerError("IsOfficialReviewer", err) ctx.ServerError("IsOfficialReviewer", err)
return return
} }
} }
}
RetrieveRepoReviewers(ctx, repo, issue, canChooseReviewer) RetrieveRepoReviewers(ctx, repo, issue, canChooseReviewer)
if ctx.Written() { if ctx.Written() {

@ -131,7 +131,10 @@ func IsValidReviewRequest(ctx context.Context, reviewer, doer *user_model.User,
return nil return nil
} }
pemResult = doer.ID == issue.PosterID
if !pemResult {
pemResult = permDoer.CanAccessAny(perm.AccessModeWrite, unit.TypePullRequests) pemResult = permDoer.CanAccessAny(perm.AccessModeWrite, unit.TypePullRequests)
}
if !pemResult { if !pemResult {
pemResult, err = issues_model.IsOfficialReviewer(ctx, issue, doer) pemResult, err = issues_model.IsOfficialReviewer(ctx, issue, doer)
if err != nil { if err != nil {
@ -201,7 +204,7 @@ func IsValidTeamReviewRequest(ctx context.Context, reviewer *organization.Team,
} }
doerCanWrite := permission.CanAccessAny(perm.AccessModeWrite, unit.TypePullRequests) doerCanWrite := permission.CanAccessAny(perm.AccessModeWrite, unit.TypePullRequests)
if !doerCanWrite { if !doerCanWrite && doer.ID != issue.PosterID {
official, err := issues_model.IsOfficialReviewer(ctx, issue, doer) official, err := issues_model.IsOfficialReviewer(ctx, issue, doer)
if err != nil { if err != nil {
log.Error("Unable to Check if IsOfficialReviewer for %-v in %-v#%d", doer, issue.Repo, issue.Index) log.Error("Unable to Check if IsOfficialReviewer for %-v in %-v#%d", doer, issue.Repo, issue.Index)

Loading…
Cancel
Save