Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5988621
ApiEchoMarkSeen.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ApiEchoMarkSeen.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications\Api
;
// This is a GET module, not a POST module, for multi-DC support. See T222851.
// Note that this module doesn't write to the database, only to the seentime cache.
use
MediaWiki\Api\ApiBase
;
use
MediaWiki\Extension\Notifications\SeenTime
;
use
Wikimedia\ParamValidator\ParamValidator
;
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
->
isRegistered
()
)
{
$this
->
dieWithError
(
'apierror-mustbeloggedin-generic'
,
'login-required'
);
}
$params
=
$this
->
extractRequestParams
();
$timestamp
=
wfTimestamp
(
TS_MW
);
$seenTime
=
SeenTime
::
newFromUser
(
$user
);
$seenTime
->
setTime
(
$timestamp
,
$params
[
'type'
]
);
if
(
$params
[
'timestampFormat'
]
===
'ISO_8601'
)
{
$outputTimestamp
=
wfTimestamp
(
TS_ISO_8601
,
$timestamp
);
}
else
{
// MW
$this
->
addDeprecation
(
'apiwarn-echo-deprecation-timestampformat'
,
'action=echomarkseen×tampFormat=MW'
);
$outputTimestamp
=
$timestamp
;
}
$this
->
getResult
()->
addValue
(
'query'
,
$this
->
getModuleName
(),
[
'result'
=>
'success'
,
'timestamp'
=>
$outputTimestamp
,
]
);
}
public
function
getAllowedParams
()
{
return
[
'type'
=>
[
ParamValidator
::
PARAM_REQUIRED
=>
true
,
ParamValidator
::
PARAM_TYPE
=>
[
'alert'
,
'message'
,
'all'
],
],
'timestampFormat'
=>
[
// Not using the TS constants, since clients can't.
ParamValidator
::
PARAM_DEFAULT
=>
'MW'
,
ParamValidator
::
PARAM_TYPE
=>
[
'ISO_8601'
,
'MW'
],
],
];
}
/**
* @see ApiBase::getExamplesMessages()
* @return string[]
*/
protected
function
getExamplesMessages
()
{
return
[
'action=echomarkseen&type=all'
=>
'apihelp-echomarkseen-example-1'
,
];
}
public
function
getHelpUrls
()
{
return
'https://www.mediawiki.org/wiki/Special:MyLanguage/Echo_(Notifications)/API'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Oct 4, 00:52 (3 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9a/4f/e9773c402d6fa041477dc6cdcea5
Default Alt Text
ApiEchoMarkSeen.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment