示例#1
0
 /**
  * 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
  */
 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();
     }
 }
示例#2
0
 public function updateUriKeys($profile_uri, array $hints = array())
 {
     $orig = clone $this;
     common_debug('URIFIX These identities both say they are each other: "' . $orig->uri . '" and "' . $profile_uri . '"');
     $this->uri = $profile_uri;
     if (array_key_exists('feedurl', $hints)) {
         if (!empty($this->feeduri)) {
             common_debug('URIFIX Changing FeedSub [' . $feedsub->id . '] feeduri "' . $feedsub->uri . '" to "' . $hints['feedurl']);
             $feedsub = FeedSub::getKV('uri', $this->feeduri);
             $feedorig = clone $feedsub;
             $feedsub->uri = $hints['feedurl'];
             $feedsub->updateWithKeys($feedorig);
         } else {
             common_debug('URIFIX Old Ostatus_profile did not have feedurl set, ensuring feed: ' . $hints['feedurl']);
             FeedSub::ensureFeed($hints['feedurl']);
         }
         $this->feeduri = $hints['feedurl'];
     }
     if (array_key_exists('salmon', $hints)) {
         common_debug('URIFIX Changing Ostatus_profile salmonuri from "' . $this->salmonuri . '" to "' . $hints['salmon'] . '"');
         $this->salmonuri = $hints['salmon'];
     }
     common_debug('URIFIX Updating Ostatus_profile URI for ' . $orig->uri . ' to ' . $this->uri);
     $this->updateWithKeys($orig, 'uri');
     // 'uri' is the primary key column
     common_debug('URIFIX Subscribing/renewing feedsub for Ostatus_profile ' . $this->uri);
     $this->subscribe();
 }
示例#3
0
}
print "\n";
print "Pinging hub {$sub->huburi} with new subscription for {$sub->uri}\n";
$ok = $sub->subscribe();
if ($ok) {
    print "ok\n";
} else {
    print "Could not confirm.\n";
}
$o2 = Ostatus_profile::staticGet('uri', $uri);
print "\n";
print "New profile state:\n";
showProfile($o2);
print "\n";
print "New feed state:\n";
$sub2 = FeedSub::ensureFeed($feedurl);
showSub($sub2);
function showProfile($oprofile)
{
    print "  Feed URL: {$oprofile->feeduri}\n";
    print "  Salmon URL: {$oprofile->salmonuri}\n";
    print "  Avatar URL: {$oprofile->avatar}\n";
    print "  Profile ID: {$oprofile->profile_id}\n";
    print "  Group ID: {$oprofile->group_id}\n";
    print "  Record created: {$oprofile->created}\n";
    print "  Record modified: {$oprofile->modified}\n";
}
function showSub($sub)
{
    print "  Subscription state: {$sub->sub_state}\n";
    print "  Verify token: {$sub->verify_token}\n";