diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-11-22 07:44:48 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-22 10:44:48 -0500 |
commit | fe49cb0243bed03f565269d84836bf21a0597665 (patch) | |
tree | bd8ea4fcb3d2201f2b294c6b8eddc7f6cc1de516 /routers/api/v1 | |
parent | bc7d599030cad2e69139b79ad5a878504fbf8ed9 (diff) | |
download | gitea-fe49cb0243bed03f565269d84836bf21a0597665.tar.gz gitea-fe49cb0243bed03f565269d84836bf21a0597665.zip |
Fix get reviewers' bug (#32415)
This PR rewrites `GetReviewer` function and move it to service layer.
Reviewers should not be watchers, so that this PR removed all watchers
from reviewers. When the repository is under an organization, the pull
request unit read permission will be checked to resolve the bug of
#32394
Fix #32394
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/repo/collaborators.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go index ea9d8b0f37..0bbf5a1ea4 100644 --- a/routers/api/v1/repo/collaborators.go +++ b/routers/api/v1/repo/collaborators.go @@ -17,6 +17,8 @@ import ( "code.gitea.io/gitea/routers/api/v1/utils" "code.gitea.io/gitea/services/context" "code.gitea.io/gitea/services/convert" + issue_service "code.gitea.io/gitea/services/issue" + pull_service "code.gitea.io/gitea/services/pull" repo_service "code.gitea.io/gitea/services/repository" ) @@ -320,7 +322,13 @@ func GetReviewers(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - reviewers, err := repo_model.GetReviewers(ctx, ctx.Repo.Repository, ctx.Doer.ID, 0) + canChooseReviewer := issue_service.CanDoerChangeReviewRequests(ctx, ctx.Doer, ctx.Repo.Repository, 0) + if !canChooseReviewer { + ctx.Error(http.StatusForbidden, "GetReviewers", errors.New("doer has no permission to get reviewers")) + return + } + + reviewers, err := pull_service.GetReviewers(ctx, ctx.Repo.Repository, ctx.Doer.ID, 0) if err != nil { ctx.Error(http.StatusInternalServerError, "ListCollaborators", err) return |