From 9534ea0e6b54cd899ac4432f1ae8f14258613ae6 Mon Sep 17 00:00:00 2001 From: Purexo Date: Mon, 23 Nov 2015 08:30:00 +0100 Subject: Update greader.php streamContents can know exclude target unread item --- p/api/greader.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'p/api') diff --git a/p/api/greader.php b/p/api/greader.php index b9942f0bc..3fa367299 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -361,6 +361,9 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex case 'user/-/state/com.google/read': $state = FreshRSS_Entry::STATE_NOT_READ; break; + case 'user/-/state/com.google/unread': + $state = FreshRSS_Entry::STATE_READ; + break; default: $state = FreshRSS_Entry::STATE_ALL; break; -- cgit v1.2.3 From 0915772fe6735f6051c6b56a3b3e59dd3c44833b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 24 Jan 2016 11:06:20 +0100 Subject: PubSubHubbub unsubscribe request https://github.com/FreshRSS/FreshRSS/issues/1058 --- app/Models/Feed.php | 9 ++++----- p/api/pshb.php | 9 +++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'p/api') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 23491ee8d..986cc5015 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -451,6 +451,10 @@ class FreshRSS_Feed extends Minz_Model { Minz_Log::warning('Invalid callback for PubSubHubbub: ' . $this->url); return false; } + if (!$state) { //unsubscribe + $hubJson['lease_end'] = time() - 60; + file_put_contents($hubFilename, json_encode($hubJson)); + } $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $this->hubUrl, @@ -470,11 +474,6 @@ class FreshRSS_Feed extends Minz_Model { 'PubSubHubbub ' . ($state ? 'subscribe' : 'unsubscribe') . ' to ' . $this->selfUrl . ' with callback ' . $callbackUrl . ': ' . $info['http_code'] . ' ' . $response . "\n", FILE_APPEND); - if (!$state) { //unsubscribe - $hubJson['lease_end'] = time() - 60; - file_put_contents($hubFilename, json_encode($hubJson)); - } - if (substr($info['http_code'], 0, 1) == '2') { return true; } else { diff --git a/p/api/pshb.php b/p/api/pshb.php index 4bb4694b3..7de4cc1a2 100644 --- a/p/api/pshb.php +++ b/p/api/pshb.php @@ -68,6 +68,15 @@ if (!empty($_REQUEST['hub_mode']) && $_REQUEST['hub_mode'] === 'subscribe') { exit(isset($_REQUEST['hub_challenge']) ? $_REQUEST['hub_challenge'] : ''); } +if (!empty($_REQUEST['hub_mode']) && $_REQUEST['hub_mode'] === 'unsubscribe') { + if (empty($hubJson['lease_end']) || $hubJson['lease_end'] < time()) { + exit(isset($_REQUEST['hub_challenge']) ? $_REQUEST['hub_challenge'] : ''); + } else { + header('HTTP/1.1 422 Unprocessable Entity'); + die('We did not ask to unsubscribe!'); + } +} + if ($ORIGINAL_INPUT == '') { header('HTTP/1.1 422 Unprocessable Entity'); die('Missing XML payload!'); -- cgit v1.2.3 From 7db99b838223649fe3aec973516b8d32d58ca5dd Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 8 Mar 2016 19:30:24 +0100 Subject: API limit INPUT to 1MB --- p/api/greader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'p/api') diff --git a/p/api/greader.php b/p/api/greader.php index 3fa367299..62782ce1a 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -23,7 +23,7 @@ Server-side API compatible with Google Reader API layer 2 require('../../constants.php'); require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader -$ORIGINAL_INPUT = file_get_contents('php://input'); +$ORIGINAL_INPUT = file_get_contents('php://input', false, null, -1, 1048576); if (PHP_INT_SIZE < 8) { //32-bit function dec2hex($dec) { -- cgit v1.2.3