mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Merge "Allow requesting TS_ISO_8601 for ApiEchoMarkSeen, and deprecate TS_MW"
This commit is contained in:
commit
bf502f89a0
|
@ -222,6 +222,7 @@
|
|||
"apihelp-echomarkseen-description": "Mark notifications as seen for the current user.",
|
||||
"apihelp-echomarkseen-example-1": "Mark notifications of all types as seen",
|
||||
"apihelp-echomarkseen-param-type": "Type of notifications to mark as seen: 'alert', 'message' or 'all'.",
|
||||
"apihelp-echomarkseen-param-timestampFormat": "Timestamp format to use for output, 'ISO_8601' or 'MW'. 'MW' is deprecated here, so all clients should switch to 'ISO_8601'. This parameter will be removed, and 'ISO_8601' will become the only output format.",
|
||||
"apihelp-query+notifications-description": "Get notifications waiting for the current user.",
|
||||
"apihelp-query+notifications-param-prop": "Details to request.",
|
||||
"apihelp-query+notifications-param-sections": "The notification sections to query (i.e. some combination of 'alert' and 'message').",
|
||||
|
|
|
@ -214,6 +214,7 @@
|
|||
"apihelp-echomarkseen-description": "{{doc-apihelp-description|echomarkseen}}",
|
||||
"apihelp-echomarkseen-example-1": "{{doc-apihelp-example|echomarkseen}}",
|
||||
"apihelp-echomarkseen-param-type": "{{doc-apihelp-param|query+notifications|type}} Do not translate the quoted strings.",
|
||||
"apihelp-echomarkseen-param-timestampFormat": "{{doc-apihelp-param|query+notifications|timestampFormat}} Do not translate the quoted strings.",
|
||||
"apihelp-query+notifications-description": "{{doc-apihelp-description|query+notifications}}",
|
||||
"apihelp-query+notifications-param-prop": "{{doc-apihelp-param|query+notifications|prop}}",
|
||||
"apihelp-query+notifications-param-sections": "{{doc-apihelp-param|query+notifications|sections}} Do not translate the quoted strings.",
|
||||
|
|
|
@ -73,6 +73,12 @@ class EchoSeenTime {
|
|||
return $formattedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the seen time
|
||||
*
|
||||
* @param string $time Time, in TS_MW format
|
||||
* @param string $type Type of seen time to set
|
||||
*/
|
||||
public function setTime( $time, $type = 'all' ) {
|
||||
if ( $type === 'all' ) {
|
||||
foreach ( self::$allowedTypes as $allowed ) {
|
||||
|
|
|
@ -16,9 +16,21 @@ class ApiEchoMarkSeen extends ApiBase {
|
|||
$seenTime = EchoSeenTime::newFromUser( $user );
|
||||
$seenTime->setTime( $timestamp, $params['type'] );
|
||||
|
||||
if ( $params['timestampFormat'] === 'ISO_8601' ) {
|
||||
$outputTimestamp = wfTimestamp( TS_ISO_8601, $timestamp );
|
||||
} else {
|
||||
// MW
|
||||
$this->setWarning( 'The MW timestamp output format is deprecated' .
|
||||
' here. In the future, ISO 8601 will always be used for ' .
|
||||
'the output timestamp format. Adjust your client and ' .
|
||||
'set timestampFormat to \'ISO_8601\'.' );
|
||||
|
||||
$outputTimestamp = $timestamp;
|
||||
}
|
||||
|
||||
$this->getResult()->addValue( 'query', $this->getModuleName(), array(
|
||||
'result' => 'success',
|
||||
'timestamp' => $timestamp,
|
||||
'timestamp' => $outputTimestamp,
|
||||
) );
|
||||
}
|
||||
|
||||
|
@ -30,7 +42,12 @@ class ApiEchoMarkSeen extends ApiBase {
|
|||
'type' => array(
|
||||
ApiBase::PARAM_REQUIRED => true,
|
||||
ApiBase::PARAM_TYPE => array( 'alert', 'message', 'all' ),
|
||||
)
|
||||
),
|
||||
'timestampFormat' => array(
|
||||
// Not using the TS constants, since clients can't.
|
||||
ApiBase::PARAM_DFLT => 'MW',
|
||||
ApiBase::PARAM_TYPE => array( 'ISO_8601', 'MW' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue