Permalink
Browse files

remove the subscription record upon successful unsubscribe

  • Loading branch information...
1 parent 1675abc commit 85be9d7c54788fd2bb18f828220ee9f0aa0092ba @quocvu committed Dec 27, 2012
@@ -744,7 +744,7 @@ protected function _getRequestParameters($hubUrl, $mode)
'verify_token' => hash('sha256', $params['hub.verify_token']),
'secret' => null,
'expiration_time' => $expires,
- 'subscription_state' => PubSubHubbub::SUBSCRIPTION_NOTVERIFIED,
+ 'subscription_state' => ($mode == 'unsubscribe')? PubSubHubbub::SUBSCRIPTION_TODELETE : PubSubHubbub::SUBSCRIPTION_NOTVERIFIED,
);
$this->getStorage()->setSubscription($data);
@@ -93,13 +93,19 @@ public function handle(array $httpGetData = null, $sendResponseNow = false)
* Handle any (un)subscribe confirmation requests
*/
} elseif ($this->isValidHubVerification($httpGetData)) {
- $data = $this->currentSubscriptionData;
$this->getHttpResponse()->setContent($httpGetData['hub_challenge']);
- $data['subscription_state'] = PubSubHubbub\PubSubHubbub::SUBSCRIPTION_VERIFIED;
- if (isset($httpGetData['hub_lease_seconds'])) {
- $data['lease_seconds'] = $httpGetData['hub_lease_seconds'];
+
+ if ($httpGetData['hub_mode'] == 'subscribe') {
+ $data = $this->currentSubscriptionData;
+ $data['subscription_state'] = PubSubHubbub\PubSubHubbub::SUBSCRIPTION_VERIFIED;
+ if (isset($httpGetData['hub_lease_seconds'])) {
+ $data['lease_seconds'] = $httpGetData['hub_lease_seconds'];
+ }
+ $this->getStorage()->setSubscription($data);
+ } else {
+ $verifyTokenKey = $this->_detectVerifyTokenKey($httpGetData);
+ $this->getStorage()->deleteSubscription($verifyTokenKey);
}
- $this->getStorage()->setSubscription($data);
/**
* Hey, C'mon! We tried everything else!
*/

0 comments on commit 85be9d7

Please sign in to comment.