Merge "Api: Minor code updates"

This commit is contained in:
jenkins-bot 2022-10-15 18:04:22 +00:00 committed by Gerrit Code Review
commit 391ebd4b8b
4 changed files with 23 additions and 20 deletions

View file

@ -7,6 +7,7 @@ use DateInterval;
use DateTime;
use EchoEvent;
use MWTimestamp;
use Wikimedia\ParamValidator\ParamValidator;
class ApiEchoArticleReminder extends ApiBase {
@ -62,20 +63,20 @@ class ApiEchoArticleReminder extends ApiBase {
public function getAllowedParams() {
return [
'pageid' => [
ApiBase::PARAM_TYPE => 'integer',
ParamValidator::PARAM_TYPE => 'integer',
],
'title' => [
ApiBase::PARAM_TYPE => 'string',
ParamValidator::PARAM_TYPE => 'string',
],
'comment' => [
ApiBase::PARAM_TYPE => 'string',
ParamValidator::PARAM_TYPE => 'string',
],
'timestamp' => [
ApiBase::PARAM_REQUIRED => true,
ApiBase::PARAM_TYPE => 'timestamp',
ParamValidator::PARAM_REQUIRED => true,
ParamValidator::PARAM_TYPE => 'timestamp',
],
'token' => [
ApiBase::PARAM_REQUIRED => true,
ParamValidator::PARAM_REQUIRED => true,
],
];
}

View file

@ -8,6 +8,7 @@ use EchoNotificationController;
use MWEchoDbFactory;
use MWEchoNotifUser;
use WikiMap;
use Wikimedia\ParamValidator\ParamValidator;
class ApiEchoMarkRead extends ApiBase {
use ApiCrossWiki;
@ -81,21 +82,21 @@ class ApiEchoMarkRead extends ApiBase {
public function getAllowedParams() {
return $this->getCrossWikiParams() + [
'list' => [
ApiBase::PARAM_ISMULTI => true,
ParamValidator::PARAM_ISMULTI => true,
],
'unreadlist' => [
ApiBase::PARAM_ISMULTI => true,
ParamValidator::PARAM_ISMULTI => true,
],
'all' => [
ApiBase::PARAM_REQUIRED => false,
ApiBase::PARAM_TYPE => 'boolean'
ParamValidator::PARAM_REQUIRED => false,
ParamValidator::PARAM_TYPE => 'boolean'
],
'sections' => [
ApiBase::PARAM_TYPE => EchoAttributeManager::$sections,
ApiBase::PARAM_ISMULTI => true,
ParamValidator::PARAM_TYPE => EchoAttributeManager::$sections,
ParamValidator::PARAM_ISMULTI => true,
],
'token' => [
ApiBase::PARAM_REQUIRED => true,
ParamValidator::PARAM_REQUIRED => true,
]
];
}

View file

@ -6,6 +6,7 @@ namespace MediaWiki\Extension\Notifications\Api;
// Note that this module doesn't write to the database, only to the seentime cache.
use ApiBase;
use EchoSeenTime;
use Wikimedia\ParamValidator\ParamValidator;
class ApiEchoMarkSeen extends ApiBase {
@ -44,13 +45,13 @@ class ApiEchoMarkSeen extends ApiBase {
public function getAllowedParams() {
return [
'type' => [
ApiBase::PARAM_REQUIRED => true,
ApiBase::PARAM_TYPE => [ 'alert', 'message', 'all' ],
ParamValidator::PARAM_REQUIRED => true,
ParamValidator::PARAM_TYPE => [ 'alert', 'message', 'all' ],
],
'timestampFormat' => [
// Not using the TS constants, since clients can't.
ApiBase::PARAM_DFLT => 'MW',
ApiBase::PARAM_TYPE => [ 'ISO_8601', 'MW' ],
ParamValidator::PARAM_DEFAULT => 'MW',
ParamValidator::PARAM_TYPE => [ 'ISO_8601', 'MW' ],
],
];
}

View file

@ -230,7 +230,7 @@ class ApiEchoUnreadNotificationPages extends ApiQueryBase {
* @return array[]
*/
public function getAllowedParams() {
global $wgEchoMaxUpdateCount;
$maxUpdateCount = $this->getConfig()->get( 'EchoMaxUpdateCount' );
return $this->getCrossWikiParams() + [
'grouppages' => [
@ -241,8 +241,8 @@ class ApiEchoUnreadNotificationPages extends ApiQueryBase {
ParamValidator::PARAM_TYPE => 'limit',
ParamValidator::PARAM_DEFAULT => 10,
IntegerDef::PARAM_MIN => 1,
IntegerDef::PARAM_MAX => $wgEchoMaxUpdateCount,
IntegerDef::PARAM_MAX2 => $wgEchoMaxUpdateCount,
IntegerDef::PARAM_MAX => $maxUpdateCount,
IntegerDef::PARAM_MAX2 => $maxUpdateCount,
],
// there is no `offset` or `continue` value: the set of possible
// notifications is small enough to allow fetching all of them at