diff --git a/docs/json-rpc-api.markdown b/docs/json-rpc-api.markdown
index 68162a3..b33b7b0 100644
--- a/docs/json-rpc-api.markdown
+++ b/docs/json-rpc-api.markdown
@@ -410,7 +410,7 @@ Response example:
### getItems
-- Purpose: **Get list o items**
+- Purpose: **Get list of items**
- Parameters:
- **since_id** (integer, optional) Returns only feeds from this item id
- **item_ids** ([]integer, optional) Returns only items in this list
@@ -433,6 +433,61 @@ Request example:
Response example:
+```json
+{
+ "jsonrpc": "2.0",
+ "result": [
+ {
+ "id": "3",
+ "checksum": "7f4b791f",
+ "title": "Miniflux 1.1.8 released",
+ "updated": "1442016000",
+ "url": "https:\/\/miniflux.net\/news\/version-1.1.8",
+ "enclosure_url": "",
+ "enclosure_type": "",
+ "bookmark": "0",
+ "feed_id": "1",
+ "status": "unread",
+ "content": "
\n- Add feed groups (tags)<\/li>\n
- Add custom rules directory support<\/li>\n
- Add no referrer policy in meta tags and content security directives<\/li>\n
- Update of PicoFeed with new scraper rules<\/li>\n
- Enable Strict-Transport-Security header for HTTPS<\/li>\n
- Change CSP directives to allow data url (Fix issue with Firefox 40)<\/li>\n
- Toggle text direction for full content preview as well<\/li>\n
- Add Russian translation<\/li>\n
- Updated Czech translation<\/li>\n
- Mark items on page 2+ read as well<\/li>\n
- Allow to override the maximum feed size limit<\/li>\n
- Added a config option to select how many concurrent refreshes are done on the subscription page<\/li>\n
- Catch exceptions for image proxy<\/li>\n
- Improve CSS for preview full content<\/li>\n
- Minor feed edit dialog improvements<\/li>\n
- Expose all feed errors to the frontend when adding a subscription<\/li>\n
- Keep selected options on feed adding error<\/li>\n
- Fix bug when the summery helper doesn't contains whitespace<\/li>\n
- Fix Fever API bug: enable send bookmark to third-party services<\/li>\n<\/ul>\n
Thanks to all contributors!<\/strong><\/p>\nDownload archive<\/a><\/p>",
+ "language": "",
+ "rtl": "0",
+ "author": "Fr\u00e9d\u00e9ric Guillot",
+ "site_url": "https:\/\/miniflux.net\/",
+ "feed_title": "Miniflux"
+ },
+ [..]
+ ],
+ "id":84429548
+}
+```
+### getItemsByStatus
+
+- Purpose: **Get list of items by status**
+- Parameters:
+ - **status** (string)
+ - **feed_ids** ([]integer, optional) Returns only items from this list of feeds
+ - **offset** (integer, optional) Number of offset items (used for pagination)
+ - **limit** (integer, optional, default=50) Change number of items returned
+ - **order_column** (string, optional, default='updated') Order table column
+ - **order_direction** (string, optional, default='desc') Order direction
+- Result on success: **list of item objects**
+- Result on failure: **false**
+
+Request example:
+
+```json
+{
+ "jsonrpc": "2.0",
+ "method": "getItems",
+ "id": 84429548,
+ "params": {
+ "status": "unread"
+ }
+}
+```
+
+Response example:
+
```json
{
"jsonrpc": "2.0",
@@ -732,4 +787,4 @@ Response example:
],
"id": 1029539064
}
-```
\ No newline at end of file
+```
diff --git a/jsonrpc.php b/jsonrpc.php
index 219455b..99de0cd 100644
--- a/jsonrpc.php
+++ b/jsonrpc.php
@@ -134,6 +134,12 @@ $procedureHandler->withCallback('getItems', function ($since_id = null, array $i
return Model\Item\get_items($user_id, $since_id, $item_ids, $limit);
});
+// Get items by status
+$procedureHandler->withCallback('getItemsByStatus', function ($status, array $feed_ids = array(), $offset = null, $limit = 50, $order_column = 'updated', $order_direction = 'desc') {
+ $user_id = SessionStorage::getInstance()->getUserId();
+ return Model\Item\get_items_by_status($user_id, $status, $feed_ids, $offset, $limit, $order_column, $order_direction);
+});
+
// Get one item
$procedureHandler->withCallback('getItem', function ($item_id) {
$user_id = SessionStorage::getInstance()->getUserId();
diff --git a/tests/functional/ApiTest.php b/tests/functional/ApiTest.php
index f8425e1..50efcc0 100644
--- a/tests/functional/ApiTest.php
+++ b/tests/functional/ApiTest.php
@@ -101,6 +101,50 @@ class ApiTest extends BaseApiTest
$this->assertNotEmpty($items[0]['url']);
}
+ public function testGetItemsByStatusUnread()
+ {
+ $items = $this->getApiClient()->getItemsByStatus(array('status' => 'unread'));
+ $this->assertNotEmpty($items);
+ $this->assertEquals(1, $items[0]['id']);
+ $this->assertEquals(1, $items[0]['feed_id']);
+ $this->assertNotEmpty($items[0]['title']);
+ $this->assertNotEmpty($items[0]['author']);
+ $this->assertNotEmpty($items[0]['content']);
+ $this->assertNotEmpty($items[0]['url']);
+ $this->assertEquals('unread', $items[0]['status']);
+ }
+
+ public function testGetItemsByStatusRead()
+ {
+ $items = $this->getApiClient()->getItemsByStatus(array('status' => 'read'));
+ $this->assertEmpty($items);
+ }
+
+ public function testGetItemsByFeedIds()
+ {
+ $items = $this->getApiClient()->getItemsByStatus(array(
+ 'status' => 'unread',
+ 'feed_ids' => array(1)
+ ));
+ $this->assertNotEmpty($items);
+ $this->assertEquals(1, $items[0]['id']);
+ $this->assertEquals(1, $items[0]['feed_id']);
+ $this->assertNotEmpty($items[0]['title']);
+ $this->assertNotEmpty($items[0]['author']);
+ $this->assertNotEmpty($items[0]['content']);
+ $this->assertNotEmpty($items[0]['url']);
+ $this->assertEquals('unread', $items[0]['status']);
+ }
+
+ public function testGetItemsByFeedIdsNonExist()
+ {
+ $items = $this->getApiClient()->getItemsByStatus(array(
+ 'status' => 'unread',
+ 'feed_ids' => array(2)
+ ));
+ $this->assertEmpty($items);
+ }
+
public function testGetItemsSinceId()
{
$items = $this->getApiClient()->getItems(array('since_id' => 2));