diff options
author | 6543 <6543@obermui.de> | 2021-06-17 16:02:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-17 16:02:34 +0200 |
commit | b3fbd37e992cf3f9f42f49818087c67d464000eb (patch) | |
tree | ddb4aee79d6dfafaa3ff64acffed6f119c222acd /routers/api/v1/repo | |
parent | 0db1048c3ab0b0802779fd84b86c4335c37e54b3 (diff) | |
download | gitea-b3fbd37e992cf3f9f42f49818087c67d464000eb.tar.gz gitea-b3fbd37e992cf3f9f42f49818087c67d464000eb.zip |
[API] expose repo.GetReviewers() & repo.GetAssignees() (#16168)
* API: expose repo.GetReviewers() & repo.GetAssignees()
* Add tests
* fix unrelated swagger query type
Diffstat (limited to 'routers/api/v1/repo')
-rw-r--r-- | routers/api/v1/repo/collaborators.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go index d0936019fa..078af1f6ff 100644 --- a/routers/api/v1/repo/collaborators.go +++ b/routers/api/v1/repo/collaborators.go @@ -221,3 +221,63 @@ func DeleteCollaborator(ctx *context.APIContext) { } ctx.Status(http.StatusNoContent) } + +// GetReviewers return all users that can be requested to review in this repo +func GetReviewers(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/reviewers repository repoGetReviewers + // --- + // summary: Return all users that can be requested to review in this repo + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/UserList" + + reviewers, err := ctx.Repo.Repository.GetReviewers(ctx.User.ID, 0) + if err != nil { + ctx.Error(http.StatusInternalServerError, "ListCollaborators", err) + return + } + ctx.JSON(http.StatusOK, convert.ToUsers(ctx.User, reviewers)) +} + +// GetAssignees return all users that have write access and can be assigned to issues +func GetAssignees(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/assignees repository repoGetAssignees + // --- + // summary: Return all users that have write access and can be assigned to issues + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/UserList" + + assignees, err := ctx.Repo.Repository.GetAssignees() + if err != nil { + ctx.Error(http.StatusInternalServerError, "ListCollaborators", err) + return + } + ctx.JSON(http.StatusOK, convert.ToUsers(ctx.User, assignees)) +} |