mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Remove duplicate logic in initListSubmits (#12660)
* Remove duplicate logic in initListSubmits Using the same logic to handle Choosing reviewers and assignees as choosing label. It's the first step of #10926. Signed-off-by: a1012112796 <1012112796@qq.com> * fix choose block * fix nit * try fix bug * simple code Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
@@ -1516,10 +1516,11 @@ func updatePullReviewRequest(ctx *context.Context) {
|
||||
}
|
||||
|
||||
reviewID := ctx.QueryInt64("id")
|
||||
event := ctx.Query("is_add")
|
||||
action := ctx.Query("action")
|
||||
|
||||
if event != "add" && event != "remove" {
|
||||
ctx.ServerError("updatePullReviewRequest", fmt.Errorf("is_add should not be \"%s\"", event))
|
||||
// TODO: Not support 'clear' now
|
||||
if action != "attach" && action != "detach" {
|
||||
ctx.Status(403)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1532,19 +1533,20 @@ func updatePullReviewRequest(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
err = isLegalReviewRequest(reviewer, ctx.User, event == "add", issue)
|
||||
err = isLegalReviewRequest(reviewer, ctx.User, action == "attach", issue)
|
||||
if err != nil {
|
||||
ctx.ServerError("isLegalRequestReview", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = issue_service.ReviewRequest(issue, ctx.User, reviewer, event == "add")
|
||||
err = issue_service.ReviewRequest(issue, ctx.User, reviewer, action == "attach")
|
||||
if err != nil {
|
||||
ctx.ServerError("ReviewRequest", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
ctx.ServerError("updatePullReviewRequest", fmt.Errorf("%d in %d is not Pull Request", issue.ID, issue.Repo.ID))
|
||||
ctx.Status(403)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user