@@ -794,43 +794,7 @@ func DismissPullReview(ctx *context.APIContext, opts api.DismissPullReviewOption
794
794
// "$ref": "#/responses/forbidden"
795
795
// "422":
796
796
// "$ref": "#/responses/validationError"
797
- if ! ctx .Repo .IsAdmin () {
798
- ctx .Error (http .StatusForbidden , "" , "Must be repo admin" )
799
- return
800
- }
801
- review , pr , isWrong := prepareSingleReview (ctx )
802
- if isWrong {
803
- return
804
- }
805
-
806
- if review .Type != models .ReviewTypeApprove && review .Type != models .ReviewTypeReject {
807
- ctx .Error (http .StatusForbidden , "" , "not need to dismiss this review because it's type is not Approve or change request" )
808
- return
809
- }
810
-
811
- if pr .Issue .IsClosed {
812
- ctx .Error (http .StatusForbidden , "" , "not need to dismiss this review because this pr is closed" )
813
- return
814
- }
815
-
816
- _ , err := pull_service .DismissReview (review .ID , opts .Message , ctx .User )
817
- if err != nil {
818
- ctx .Error (http .StatusInternalServerError , "pull_service.DismissReview" , err )
819
- return
820
- }
821
-
822
- if review , err = models .GetReviewByID (review .ID ); err != nil {
823
- ctx .Error (http .StatusInternalServerError , "GetReviewByID" , err )
824
- return
825
- }
826
-
827
- // convert response
828
- apiReview , err := convert .ToPullReview (review , ctx .User )
829
- if err != nil {
830
- ctx .Error (http .StatusInternalServerError , "convertToPullReview" , err )
831
- return
832
- }
833
- ctx .JSON (http .StatusOK , apiReview )
797
+ disMissReview (ctx , true )
834
798
}
835
799
836
800
// UnDismissPullReview cancel to dismiss a review for a pull request
@@ -870,6 +834,10 @@ func UnDismissPullReview(ctx *context.APIContext) {
870
834
// "$ref": "#/responses/forbidden"
871
835
// "422":
872
836
// "$ref": "#/responses/validationError"
837
+ disMissReview (ctx , false )
838
+ }
839
+
840
+ func disMissReview (ctx * context.APIContext , isDismiss bool ) {
873
841
if ! ctx .Repo .IsAdmin () {
874
842
ctx .Error (http .StatusForbidden , "" , "Must be repo admin" )
875
843
return
@@ -889,12 +857,12 @@ func UnDismissPullReview(ctx *context.APIContext) {
889
857
return
890
858
}
891
859
892
- if err := pull_service .UnDismissReview (review .ID ); err != nil {
860
+ _ , err := pull_service .DismissReview (review .ID , opts .Message , ctx .User , isDismiss )
861
+ if err != nil {
893
862
ctx .Error (http .StatusInternalServerError , "pull_service.DismissReview" , err )
894
863
return
895
864
}
896
865
897
- var err error
898
866
if review , err = models .GetReviewByID (review .ID ); err != nil {
899
867
ctx .Error (http .StatusInternalServerError , "GetReviewByID" , err )
900
868
return
0 commit comments