@@ -640,6 +640,8 @@ func DeleteReviewRequests(ctx *context.APIContext) {
640640 // "$ref": "#/responses/empty"
641641 // "422":
642642 // "$ref": "#/responses/validationError"
643+ // "403":
644+ // "$ref": "#/responses/forbidden"
643645 // "404":
644646 // "$ref": "#/responses/notFound"
645647 opts := web .GetForm (ctx ).(* api.PullReviewRequestOptions )
@@ -708,6 +710,10 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions
708710 for _ , reviewer := range reviewers {
709711 comment , err := issue_service .ReviewRequest (ctx , pr .Issue , ctx .Doer , reviewer , isAdd )
710712 if err != nil {
713+ if issues_model .IsErrReviewRequestOnClosedPR (err ) {
714+ ctx .Error (http .StatusForbidden , "" , err )
715+ return
716+ }
711717 ctx .Error (http .StatusInternalServerError , "ReviewRequest" , err )
712718 return
713719 }
@@ -874,7 +880,7 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
874880 ctx .Error (http .StatusForbidden , "" , "Must be repo admin" )
875881 return
876882 }
877- review , pr , isWrong := prepareSingleReview (ctx )
883+ review , _ , isWrong := prepareSingleReview (ctx )
878884 if isWrong {
879885 return
880886 }
@@ -884,13 +890,12 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss, dismissPriors
884890 return
885891 }
886892
887- if pr .Issue .IsClosed {
888- ctx .Error (http .StatusForbidden , "" , "not need to dismiss this review because this pr is closed" )
889- return
890- }
891-
892893 _ , err := pull_service .DismissReview (ctx , review .ID , ctx .Repo .Repository .ID , msg , ctx .Doer , isDismiss , dismissPriors )
893894 if err != nil {
895+ if pull_service .IsErrDismissRequestOnClosedPR (err ) {
896+ ctx .Error (http .StatusForbidden , "" , err )
897+ return
898+ }
894899 ctx .Error (http .StatusInternalServerError , "pull_service.DismissReview" , err )
895900 return
896901 }
0 commit comments