mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-04-05 07:03:29 -04:00
Merge branch 'pshb-unsubscribe' into dev
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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!');
|
||||
|
||||
Reference in New Issue
Block a user