[GITEA] DELETE /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}
* reuse deleteIssueComment by adding the commentType parameter * ensure tests start with a PR with no random reviews from fixtures Refs: https://codeberg.org/forgejo/forgejo/issues/2109 (cherry picked from commit 5b90ab77f67e4c0ac17d8b1101453d7790fa45d2) (cherry picked from commit 28ecd6f5a67891788ad4d989311050df55deb008) (cherry picked from commit 24870cf133153f0fdefb76df58fe074ae6aef7c0)
This commit is contained in:
parent
8eaa8aeaf9
commit
0b503e5e86
5 changed files with 156 additions and 6 deletions
|
@ -1265,7 +1265,11 @@ func Routes() *web.Route {
|
|||
m.Combo("").
|
||||
Get(repo.GetPullReviewComments).
|
||||
Post(reqToken(), bind(api.CreatePullReviewCommentOptions{}), repo.CreatePullReviewComment)
|
||||
m.Get("/{comment}", commentAssignment("comment"), repo.GetPullReviewComment)
|
||||
m.Group("/{comment}", func() {
|
||||
m.Combo("").
|
||||
Get(repo.GetPullReviewComment).
|
||||
Delete(reqToken(), repo.DeletePullReviewComment)
|
||||
}, commentAssignment("comment"))
|
||||
})
|
||||
m.Post("/dismissals", reqToken(), bind(api.DismissPullReviewOptions{}), repo.DismissPullReview)
|
||||
m.Post("/undismissals", reqToken(), repo.UnDismissPullReview)
|
||||
|
|
|
@ -624,7 +624,7 @@ func DeleteIssueComment(ctx *context.APIContext) {
|
|||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
deleteIssueComment(ctx)
|
||||
deleteIssueComment(ctx, issues_model.CommentTypeComment)
|
||||
}
|
||||
|
||||
// DeleteIssueCommentDeprecated delete a comment from an issue
|
||||
|
@ -663,16 +663,16 @@ func DeleteIssueCommentDeprecated(ctx *context.APIContext) {
|
|||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
deleteIssueComment(ctx)
|
||||
deleteIssueComment(ctx, issues_model.CommentTypeComment)
|
||||
}
|
||||
|
||||
func deleteIssueComment(ctx *context.APIContext) {
|
||||
func deleteIssueComment(ctx *context.APIContext, commentType issues_model.CommentType) {
|
||||
comment := ctx.Comment
|
||||
|
||||
if !ctx.IsSigned || (ctx.Doer.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
|
||||
ctx.Status(http.StatusForbidden)
|
||||
return
|
||||
} else if comment.Type != issues_model.CommentTypeComment {
|
||||
} else if comment.Type != commentType {
|
||||
ctx.Status(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1014,6 +1014,53 @@ func UnDismissPullReview(ctx *context.APIContext) {
|
|||
dismissReview(ctx, "", false, false)
|
||||
}
|
||||
|
||||
// DeletePullReviewComment delete a pull review comment
|
||||
func DeletePullReviewComment(ctx *context.APIContext) {
|
||||
// swagger:operation DELETE /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment} repository repoDeletePullReviewComment
|
||||
// ---
|
||||
// summary: Delete a pull review comment
|
||||
// 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
|
||||
// - name: index
|
||||
// in: path
|
||||
// description: index of the pull request
|
||||
// type: integer
|
||||
// format: int64
|
||||
// required: true
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: id of the review
|
||||
// type: integer
|
||||
// format: int64
|
||||
// required: true
|
||||
// - name: comment
|
||||
// in: path
|
||||
// description: id of the comment
|
||||
// type: integer
|
||||
// format: int64
|
||||
// required: true
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
deleteIssueComment(ctx, issues_model.CommentTypeCode)
|
||||
}
|
||||
|
||||
func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors bool) {
|
||||
if !ctx.Repo.IsAdmin() {
|
||||
ctx.Error(http.StatusForbidden, "", "Must be repo admin")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue