ApiQueryUserInfo: Add theoreticalratelimits
Bug: T258888 Change-Id: If2848a4905ff165f1b1ba6f26aaad8697a3f7ea4
This commit is contained in:
parent
e259f0f87d
commit
bc32baf912
3 changed files with 18 additions and 3 deletions
|
|
@ -173,7 +173,12 @@ class ApiQueryUserInfo extends ApiQueryBase {
|
|||
}
|
||||
|
||||
if ( isset( $this->prop['ratelimits'] ) ) {
|
||||
$vals['ratelimits'] = $this->getRateLimits();
|
||||
// true = real rate limits, taking User::isPingLimitable into account
|
||||
$vals['ratelimits'] = $this->getRateLimits( true );
|
||||
}
|
||||
if ( isset( $this->prop['theoreticalratelimits'] ) ) {
|
||||
// false = ignore User::isPingLimitable
|
||||
$vals['theoreticalratelimits'] = $this->getRateLimits( false );
|
||||
}
|
||||
|
||||
if ( isset( $this->prop['realname'] ) &&
|
||||
|
|
@ -240,13 +245,20 @@ class ApiQueryUserInfo extends ApiQueryBase {
|
|||
return $vals;
|
||||
}
|
||||
|
||||
protected function getRateLimits() {
|
||||
/**
|
||||
* Get the rate limits that apply to the user, or the rate limits
|
||||
* that would apply if the user didn't have `noratelimit`
|
||||
*
|
||||
* @param bool $applyNoRateLimit
|
||||
* @return array
|
||||
*/
|
||||
protected function getRateLimits( bool $applyNoRateLimit ) {
|
||||
$retval = [
|
||||
ApiResult::META_TYPE => 'assoc',
|
||||
];
|
||||
|
||||
$user = $this->getUser();
|
||||
if ( !$user->isPingLimitable() ) {
|
||||
if ( $applyNoRateLimit && !$user->isPingLimitable() ) {
|
||||
return $retval; // No limits
|
||||
}
|
||||
|
||||
|
|
@ -313,6 +325,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
|
|||
'options',
|
||||
'editcount',
|
||||
'ratelimits',
|
||||
'theoreticalratelimits',
|
||||
'email',
|
||||
'realname',
|
||||
'acceptlang',
|
||||
|
|
|
|||
|
|
@ -1342,6 +1342,7 @@
|
|||
"apihelp-query+userinfo-paramvalue-prop-preferencestoken": "Get a token to change current user's preferences.",
|
||||
"apihelp-query+userinfo-paramvalue-prop-editcount": "Adds the current user's edit count.",
|
||||
"apihelp-query+userinfo-paramvalue-prop-ratelimits": "Lists all rate limits applying to the current user.",
|
||||
"apihelp-query+userinfo-paramvalue-prop-theoreticalratelimits": "Lists all rate limits that would apply to the current user if they were not exempt from all ratelimits based on user rights or ip",
|
||||
"apihelp-query+userinfo-paramvalue-prop-realname": "Adds the user's real name.",
|
||||
"apihelp-query+userinfo-paramvalue-prop-email": "Adds the user's email address and email authentication date.",
|
||||
"apihelp-query+userinfo-paramvalue-prop-acceptlang": "Echoes the <code>Accept-Language</code> header sent by the client in a structured format.",
|
||||
|
|
|
|||
|
|
@ -1258,6 +1258,7 @@
|
|||
"apihelp-query+userinfo-paramvalue-prop-preferencestoken": "{{doc-apihelp-paramvalue|query+userinfo|prop|preferencestoken}}\n{{doc-important|You can translate the word \"Deprecated\", but please do not alter the <code><nowiki>class=\"apihelp-deprecated\"</nowiki></code> attribute}}",
|
||||
"apihelp-query+userinfo-paramvalue-prop-editcount": "{{doc-apihelp-paramvalue|query+userinfo|prop|editcount}}",
|
||||
"apihelp-query+userinfo-paramvalue-prop-ratelimits": "{{doc-apihelp-paramvalue|query+userinfo|prop|ratelimits}}",
|
||||
"apihelp-query+userinfo-paramvalue-prop-theoreticalratelimits": "{{doc-apihelp-paramvalue|query+userinfo|prop|theoreticalratelimits}}",
|
||||
"apihelp-query+userinfo-paramvalue-prop-realname": "{{doc-apihelp-paramvalue|query+userinfo|prop|realname}}",
|
||||
"apihelp-query+userinfo-paramvalue-prop-email": "{{doc-apihelp-paramvalue|query+userinfo|prop|email}}",
|
||||
"apihelp-query+userinfo-paramvalue-prop-acceptlang": "{{doc-apihelp-paramvalue|query+userinfo|prop|acceptlang}}",
|
||||
|
|
|
|||
Loading…
Reference in a new issue