aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
authorZettat123 <zettat123@gmail.com>2024-02-24 20:38:43 +0800
committerGitHub <noreply@github.com>2024-02-24 12:38:43 +0000
commitc42083a33950be6ee9f822c6d0de3c3a79d1f51b (patch)
treeabbcefa5ef6f76d7c61a15c0836efa0907d7c2d9 /routers/web
parent267dbb4e938cc42dc09a4a893cca631b2f755557 (diff)
downloadgitea-c42083a33950be6ee9f822c6d0de3c3a79d1f51b.tar.gz
gitea-c42083a33950be6ee9f822c6d0de3c3a79d1f51b.zip
Allow non-admin users to delete review requests (#29057)
Fix #14459 The following users can add/remove review requests of a PR - the poster of the PR - the owner or collaborators of the repository - members with read permission on the pull requests unit
Diffstat (limited to 'routers/web')
-rw-r--r--routers/web/repo/issue.go21
1 files changed, 4 insertions, 17 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index d5e49960a1..9f08607642 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -711,16 +711,12 @@ func RetrieveRepoReviewers(ctx *context.Context, repo *repo_model.Repository, is
tmp.ItemID = -review.ReviewerTeamID
}
- if ctx.Repo.IsAdmin() {
- // Admin can dismiss or re-request any review requests
+ if canChooseReviewer {
+ // Users who can choose reviewers can also remove review requests
tmp.CanChange = true
} else if ctx.Doer != nil && ctx.Doer.ID == review.ReviewerID && review.Type == issues_model.ReviewTypeRequest {
// A user can refuse review requests
tmp.CanChange = true
- } else if (canChooseReviewer || (ctx.Doer != nil && ctx.Doer.ID == issue.PosterID)) && review.Type != issues_model.ReviewTypeRequest &&
- ctx.Doer.ID != review.ReviewerID {
- // The poster of the PR, a manager, or official reviewers can re-request review from other reviewers
- tmp.CanChange = true
}
pullReviews = append(pullReviews, tmp)
@@ -1525,18 +1521,9 @@ func ViewIssue(ctx *context.Context) {
}
if issue.IsPull {
- canChooseReviewer := ctx.Repo.CanWrite(unit.TypePullRequests)
+ canChooseReviewer := false
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
- }
- }
+ canChooseReviewer = issue_service.CanDoerChangeReviewRequests(ctx, ctx.Doer, repo, issue)
}
RetrieveRepoReviewers(ctx, repo, issue, canChooseReviewer)