Kaldari has uploaded a new change for review.
https://gerrit.wikimedia.org/r/81157
Change subject: Adding allunread param to API for retrieving all unread
messages (up to $wgEchoMaxNotificationCount)
......................................................................
Adding allunread param to API for retrieving all unread messages
(up to $wgEchoMaxNotificationCount)
Change-Id: Ibe6b276829145c9515cb16169d58c0186687c35e
---
M api/ApiEchoNotifications.php
1 file changed, 17 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/57/81157/1
diff --git a/api/ApiEchoNotifications.php b/api/ApiEchoNotifications.php
index 20182b0..01952c3 100644
--- a/api/ApiEchoNotifications.php
+++ b/api/ApiEchoNotifications.php
@@ -32,14 +32,18 @@
$result = array();
if ( in_array( 'list', $prop ) ) {
- $result['list'] = self::getNotifications( $user,
$params['format'], $params['limit'] + 1, $params['continue'] );
-
- // check if there is more elements than we request
- if ( count( $result['list'] ) > $params['limit'] ) {
- $lastItem = array_pop( $result['list'] );
- $result['continue'] =
$lastItem['timestamp']['utcunix'] . '|' . $lastItem['id'];
+ if ( $params['allunread'] ) {
+ // getNotificationCount will return
$wgEchoMaxNotificationCount + 1 at most
+ $result['list'] = self::getNotifications(
$user, $params['format'], $notifUser->getNotificationCount() );
} else {
- $result['continue'] = null;
+ $result['list'] = self::getNotifications(
$user, $params['format'], $params['limit'] + 1, $params['continue'] );
+ // check if there are more elements than we
requested
+ if ( count( $result['list'] ) >
$params['limit'] ) {
+ $lastItem = array_pop( $result['list']
);
+ $result['continue'] =
$lastItem['timestamp']['utcunix'] . '|' . $lastItem['id'];
+ } else {
+ $result['continue'] = null;
+ }
}
$this->getResult()->setIndexedTagName( $result['list'],
'notification' );
}
@@ -184,6 +188,10 @@
'html',
),
),
+ 'allunread' => array(
+ ApiBase::PARAM_REQUIRED => false,
+ ApiBase::PARAM_TYPE => 'boolean'
+ ),
'limit' => array(
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_DFLT => 20,
@@ -202,6 +210,7 @@
'markread' => 'A list of notification IDs to mark as
read',
'markallread' => "If set to true, marks all of a user's
notifications as read",
'format' => 'If specified, notifications will be
returned formatted this way.',
+ 'allunread' => 'If set to true, all unread
notifications will be returned.',
'index' => 'If specified, a list of notification IDs,
in order, will be returned.',
'limit' => 'The maximum number of notifications to
return.',
'continue' => 'When more results are available, use
this to continue',
@@ -221,7 +230,7 @@
}
public function getHelpUrls() {
- return
'https://www.mediawiki.org/wiki/Echo_(notifications)/API';
+ return
'https://www.mediawiki.org/wiki/Echo_(Notifications)/API';
}
public function getVersion() {
--
To view, visit https://gerrit.wikimedia.org/r/81157
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe6b276829145c9515cb16169d58c0186687c35e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits