mediawiki-extensions-Echo/includes/api/ApiEchoMarkSeen.php
Kunal Mehta 35c4a37918 Use db-replicated objectcache for storing last seen time
So we're not abusing user preferences for the last seen time.
EchoSeenTime is a small wrapper around ObjectCache that handles the
fallback to user preferences during the transition.

All JavaScript code now needs to use mw.config.get('wgEchoSeenTime').

Bug: T95839
Change-Id: Ia45ba5e30eb4564250539d04d5886d2598ebd49a
2015-09-02 22:42:35 +00:00

86 lines
1.6 KiB
PHP
Executable file

<?php
class ApiEchoMarkSeen extends ApiBase {
public function execute() {
// To avoid API warning, register the parameter used to bust browser cache
$this->getMain()->getVal( '_' );
$user = $this->getUser();
if ( $user->isAnon() ) {
$this->dieUsage( 'Login is required', 'login-required' );
}
$timestamp = wfTimestamp( TS_MW );
$seenTime = EchoSeenTime::newFromUser( $user );
$seenTime->setTime( $timestamp );
$this->getResult()->addValue( 'query', $this->getModuleName(), array(
'result' => 'success',
'timestamp' => $timestamp,
) );
}
public function getAllowedParams() {
return array(
'token' => array(
ApiBase::PARAM_REQUIRED => true,
),
);
}
/**
* @deprecated since MediaWiki core 1.25
*/
public function getParamDescription() {
return array(
'token' => 'edit token',
);
}
public function needsToken() {
return 'csrf';
}
public function getTokenSalt() {
return '';
}
public function mustBePosted() {
return true;
}
public function isWriteMode() {
return true;
}
/**
* @deprecated since MediaWiki core 1.25
*/
public function getDescription() {
return 'Mark notifications as seen for the current user';
}
/**
* @deprecated since MediaWiki core 1.25
*/
public function getExamples() {
return array(
'api.php?action=echomarkseen',
);
}
/**
* @see ApiBase::getExamplesMessages()
*/
protected function getExamplesMessages() {
return array(
'action=echomarkseen' => 'apihelp-echomarkseen-example-1',
);
}
public function getHelpUrls() {
return 'https://www.mediawiki.org/wiki/Echo_(Notifications)/API';
}
}