aboutsummaryrefslogtreecommitdiff
path: root/p/api/query.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-07-24 19:39:30 +0200
committerGravatar GitHub <noreply@github.com> 2024-07-24 19:39:30 +0200
commit5267db88abf7c8546e8ba47c6d4acfd362a82e1d (patch)
tree46b40d5bae64c5ca2ded8b3c52030c0153b0680b /p/api/query.php
parenta6d7bdc7426af55ffde71ab626a096a98f650974 (diff)
Share in GReader JSON format (#6655)
fix https://github.com/FreshRSS/FreshRSS/discussions/6654#discussioncomment-10128309
Diffstat (limited to 'p/api/query.php')
-rw-r--r--p/api/query.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/p/api/query.php b/p/api/query.php
index 7d74f2313..8fe3c44b0 100644
--- a/p/api/query.php
+++ b/p/api/query.php
@@ -13,7 +13,7 @@ if (!ctype_alnum($token)) {
}
$format = Minz_Request::paramString('f');
-if (!in_array($format, ['atom', 'html', 'opml', 'rss'], true)) {
+if (!in_array($format, ['atom', 'greader', 'html', 'json', 'opml', 'rss'], true)) {
header('HTTP/1.1 422 Unprocessable Entity');
header('Content-Type: text/plain; charset=UTF-8');
die('Invalid format `f`!');
@@ -63,7 +63,9 @@ foreach (FreshRSS_Context::userConf()->queries as $raw_query) {
if (!empty($raw_query['token']) && $raw_query['token'] === $token) {
switch ($format) {
case 'atom':
+ case 'greader':
case 'html':
+ case 'json':
case 'rss':
if (empty($raw_query['shareRss'])) {
continue 2;
@@ -161,6 +163,13 @@ if (in_array($format, ['rss', 'atom'], true)) {
header('Content-Type: application/rss+xml; charset=utf-8');
$view->_layout(null);
$view->_path('index/rss.phtml');
+} elseif (in_array($format, ['greader', 'json'], true)) {
+ header('Content-Type: application/json; charset=utf-8');
+ $view->_layout(null);
+ $view->type = 'query/' . $token;
+ $view->list_title = $query->getName();
+ $view->entryIdsTagNames = []; // Do not export user labels for privacy
+ $view->_path('helpers/export/articles.phtml');
} elseif ($format === 'opml') {
if (!$query->safeForOpml()) {
Minz_Error::error(404, 'OPML not allowed for this user query!');