Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
98.57% |
69 / 70 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
ReviewHandler | |
98.57% |
69 / 70 |
|
66.67% |
2 / 3 |
4 | |
0.00% |
0 / 1 |
run | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |||
needsWriteAccess | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getParamSettings | |
100.00% |
62 / 62 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\FlaggedRevs\Rest; |
4 | |
5 | use FlaggedRevs; |
6 | use MediaWiki\Rest\Response; |
7 | use MediaWiki\Rest\SimpleHandler; |
8 | use RevisionReview; |
9 | use Wikimedia\ParamValidator\ParamValidator; |
10 | |
11 | /** |
12 | * Handler class for REST API endpoint that updates revision review items |
13 | */ |
14 | class ReviewHandler extends SimpleHandler { |
15 | |
16 | /** |
17 | * @param string $target |
18 | * @return Response |
19 | */ |
20 | public function run( $target ) { |
21 | $body = $this->getValidatedBody(); |
22 | $body[ 'target' ] = $target; |
23 | $result = RevisionReview::doReview( $body ); |
24 | $response = $this->getResponseFactory()->createJson( $result ); |
25 | if ( isset( $result[ 'error-html' ] ) ) { |
26 | $response->setStatus( 400 ); |
27 | } |
28 | return $response; |
29 | } |
30 | |
31 | public function needsWriteAccess() { |
32 | return true; |
33 | } |
34 | |
35 | /** @inheritDoc */ |
36 | public function getParamSettings() { |
37 | return [ |
38 | 'target' => [ |
39 | self::PARAM_SOURCE => 'path', |
40 | ParamValidator::PARAM_TYPE => 'string', |
41 | ParamValidator::PARAM_REQUIRED => true, |
42 | ], |
43 | 'oldid' => [ |
44 | self::PARAM_SOURCE => 'body', |
45 | ParamValidator::PARAM_TYPE => 'integer', |
46 | ParamValidator::PARAM_REQUIRED => false, |
47 | ], |
48 | 'refid' => [ |
49 | self::PARAM_SOURCE => 'body', |
50 | ParamValidator::PARAM_TYPE => 'integer', |
51 | ParamValidator::PARAM_REQUIRED => false, |
52 | ], |
53 | 'validatedParams' => [ |
54 | self::PARAM_SOURCE => 'body', |
55 | ParamValidator::PARAM_TYPE => 'string', |
56 | ParamValidator::PARAM_REQUIRED => false, |
57 | ], |
58 | 'templateParams' => [ |
59 | self::PARAM_SOURCE => 'body', |
60 | ParamValidator::PARAM_TYPE => 'string', |
61 | ParamValidator::PARAM_REQUIRED => false, |
62 | ], |
63 | 'wpApprove' => [ |
64 | self::PARAM_SOURCE => 'body', |
65 | ParamValidator::PARAM_TYPE => 'boolean', |
66 | ParamValidator::PARAM_REQUIRED => false, |
67 | ], |
68 | 'wpUnapprove' => [ |
69 | self::PARAM_SOURCE => 'body', |
70 | ParamValidator::PARAM_TYPE => 'boolean', |
71 | ParamValidator::PARAM_REQUIRED => false, |
72 | ], |
73 | 'wpReject' => [ |
74 | self::PARAM_SOURCE => 'body', |
75 | ParamValidator::PARAM_TYPE => 'boolean', |
76 | ParamValidator::PARAM_REQUIRED => false, |
77 | ], |
78 | 'wpReason' => [ |
79 | self::PARAM_SOURCE => 'body', |
80 | ParamValidator::PARAM_TYPE => 'string', |
81 | ParamValidator::PARAM_REQUIRED => false, |
82 | ], |
83 | 'changetime' => [ |
84 | self::PARAM_SOURCE => 'body', |
85 | ParamValidator::PARAM_TYPE => 'string', |
86 | ParamValidator::PARAM_REQUIRED => false, |
87 | ], |
88 | 'wpEditToken' => [ |
89 | self::PARAM_SOURCE => 'body', |
90 | ParamValidator::PARAM_TYPE => 'string', |
91 | ParamValidator::PARAM_REQUIRED => true, |
92 | ], |
93 | 'wp' . FlaggedRevs::getTagName() => [ |
94 | self::PARAM_SOURCE => 'body', |
95 | ParamValidator::PARAM_TYPE => 'integer', |
96 | ParamValidator::PARAM_REQUIRED => false, |
97 | ], |
98 | ]; |
99 | } |
100 | } |