forked from dysosmus/miniflux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonrpc.php
184 lines (123 loc) · 3.97 KB
/
jsonrpc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
require __DIR__.'/common.php';
require __DIR__.'/vendor/JsonRPC/Server.php';
use JsonRPC\Server;
$server = new Server;
$server->authentication(array(
\Model\Config\get('username') => \Model\Config\get('api_token')
));
// Get all feeds
$server->register('feed.list', function () {
return Model\Feed\get_all();
});
// Get one feed
$server->register('feed.info', function ($feed_id) {
return Model\Feed\get($feed_id);
});
// Add a new feed
$server->register('feed.create', function($url) {
$result = Model\Feed\create($url);
Model\Config\write_debug();
return $result;
});
// Delete a feed
$server->register('feed.delete', function($feed_id) {
return Model\Feed\remove($feed_id);
});
// Delete all feeds
$server->register('feed.delete_all', function() {
return Model\Feed\remove_all();
});
// Enable a feed
$server->register('feed.enable', function($feed_id) {
return Model\Feed\enable($feed_id);
});
// Disable a feed
$server->register('feed.disable', function($feed_id) {
return Model\Feed\disable($feed_id);
});
// Update a feed
$server->register('feed.update', function($feed_id) {
return Model\Feed\refresh($feed_id);
});
// Get all items for a specific feed
$server->register('item.feed.list', function ($feed_id, $offset = null, $limit = null) {
return Model\Item\get_all_by_feed($feed_id, $offset, $limit);
});
// Count all feed items
$server->register('item.feed.count', function ($feed_id) {
return Model\Item\count_by_feed($feed_id);
});
// Get all bookmark items
$server->register('item.bookmark.list', function ($offset = null, $limit = null) {
return Model\Item\get_bookmarks($offset, $limit);
});
// Count bookmarks
$server->register('item.bookmark.count', function () {
return Model\Item\count_bookmarks();
});
// Add a bookmark
$server->register('item.bookmark.create', function ($item_id) {
return Model\Item\set_bookmark_value($item_id, 1);
});
// Remove a bookmark
$server->register('item.bookmark.delete', function ($item_id) {
return Model\Item\set_bookmark_value($item_id, 0);
});
// Get all unread items
$server->register('item.list_unread', function ($offset = null, $limit = null) {
return Model\Item\get_all('unread', $offset, $limit);
});
// Count all unread items
$server->register('item.count_unread', function () {
return Model\Item\count_by_status('unread');
});
// Get all read items
$server->register('item.list_read', function ($offset = null, $limit = null) {
return Model\Item\get_all('read', $offset, $limit);
});
// Count all read items
$server->register('item.count_read', function () {
return Model\Item\count_by_status('read');
});
// Get one item
$server->register('item.info', function ($item_id) {
return Model\Item\get($item_id);
});
// Delete an item
$server->register('item.delete', function($item_id) {
return Model\Item\set_removed($item_id);
});
// Mark item as read
$server->register('item.mark_as_read', function($item_id) {
return Model\Item\set_read($item_id);
});
// Mark item as unread
$server->register('item.mark_as_unread', function($item_id) {
return Model\Item\set_unread($item_id);
});
// Change the status of list of items
$server->register('item.set_list_status', function($status, array $items) {
return Model\Item\set_status($status, $items);
});
// Flush all read items
$server->register('item.flush', function() {
return Model\Item\mark_all_as_removed();
});
// Mark all unread items as read
$server->register('item.mark_all_as_read', function() {
return Model\Item\mark_all_as_read();
});
// Get all items with the content
$server->register('item.get_all', function() {
return Model\Item\get_everything();
});
// Get all items since a date
$server->register('item.get_all_since', function($timestamp) {
return Model\Item\get_everything_since($timestamp);
});
// Get all items id and status
$server->register('item.get_all_status', function() {
return Model\Item\get_all_status();
});
echo $server->execute();