diff options
author | Jason Song <i@wolfogre.com> | 2022-09-10 01:27:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-09 18:27:47 +0100 |
commit | 831e981357dc24e45383b7d495227011a7b8f23e (patch) | |
tree | 0cba2e0c97e51d144ba3c48650cb43252bb9e722 | |
parent | b5d21c0adf38a4726b14157786be8ad11c1eda22 (diff) | |
download | gitea-831e981357dc24e45383b7d495227011a7b8f23e.tar.gz gitea-831e981357dc24e45383b7d495227011a7b8f23e.zip |
Allow poster to choose reviewers (#21084)
Allow the poster of a PR to choose reviewers (add only).
Solve #20746
-rw-r--r-- | routers/web/repo/issue.go | 15 | ||||
-rw-r--r-- | services/issue/assignee.go | 7 |
2 files changed, 15 insertions, 7 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 592f7eac8f..5dab770d55 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1336,11 +1336,16 @@ func ViewIssue(ctx *context.Context) { if issue.IsPull { canChooseReviewer := ctx.Repo.CanWrite(unit.TypePullRequests) - if !canChooseReviewer && ctx.Doer != nil && ctx.IsSigned { - canChooseReviewer, err = issues_model.IsOfficialReviewer(ctx, issue, ctx.Doer) - if err != nil { - ctx.ServerError("IsOfficialReviewer", err) - return + 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) + if err != nil { + ctx.ServerError("IsOfficialReviewer", err) + return + } } } diff --git a/services/issue/assignee.go b/services/issue/assignee.go index aefd8cff9a..e24f8500c9 100644 --- a/services/issue/assignee.go +++ b/services/issue/assignee.go @@ -131,7 +131,10 @@ func IsValidReviewRequest(ctx context.Context, reviewer, doer *user_model.User, return nil } - pemResult = permDoer.CanAccessAny(perm.AccessModeWrite, unit.TypePullRequests) + pemResult = doer.ID == issue.PosterID + if !pemResult { + pemResult = permDoer.CanAccessAny(perm.AccessModeWrite, unit.TypePullRequests) + } if !pemResult { pemResult, err = issues_model.IsOfficialReviewer(ctx, issue, doer) if err != nil { @@ -201,7 +204,7 @@ func IsValidTeamReviewRequest(ctx context.Context, reviewer *organization.Team, } doerCanWrite := permission.CanAccessAny(perm.AccessModeWrite, unit.TypePullRequests) - if !doerCanWrite { + if !doerCanWrite && doer.ID != issue.PosterID { official, err := issues_model.IsOfficialReviewer(ctx, issue, doer) if err != nil { log.Error("Unable to Check if IsOfficialReviewer for %-v in %-v#%d", doer, issue.Repo, issue.Index) |