More Exceptions for FeedSub doSubscribe and related functions

Now also garbageCollect will now throw exceptions of failures of all kinds
and only reply true/false on entirely successful runs of sub/unsub.
This commit is contained in:
Mikael Nordfeldth
2014-05-06 15:40:57 +02:00
parent 0fa00d5106
commit c279a33feb
7 changed files with 72 additions and 79 deletions

View File

@@ -199,37 +199,39 @@ class Ostatus_profile extends Managed_DataObject
* Send a subscription request to the hub for this feed.
* The hub will later send us a confirmation POST to /main/push/callback.
*
* @return bool true on success, false on failure
* @throws ServerException if feed state is not valid
* @return void
* @throws ServerException if feed state is not valid or subscription fails.
*/
public function subscribe()
{
$feedsub = FeedSub::ensureFeed($this->feeduri);
if ($feedsub->sub_state == 'active') {
// Active subscription, we don't need to do anything.
return true;
} else {
// Inactive or we got left in an inconsistent state.
// Run a subscription request to make sure we're current!
return $feedsub->subscribe();
return;
}
// Inactive or we got left in an inconsistent state.
// Run a subscription request to make sure we're current!
return $feedsub->subscribe();
}
/**
* Check if this remote profile has any active local subscriptions, and
* if not drop the PuSH subscription feed.
*
* @return bool true on success, false on failure
* @return boolean true if subscription is removed, false if there are still subscribers to the feed
* @throws Exception of various kinds on failure.
*/
public function unsubscribe() {
$this->garbageCollect();
return $this->garbageCollect();
}
/**
* Check if this remote profile has any active local subscriptions, and
* if not drop the PuSH subscription feed.
*
* @return boolean
* @return boolean true if subscription is removed, false if there are still subscribers to the feed
* @throws Exception of various kinds on failure.
*/
public function garbageCollect()
{