forked from GNUsocial/gnu-social
Change mentions of PuSH to WebSub
WebSub is probably finalised before we make a release anyway. Here is the official spec: https://www.w3.org/TR/websub/ Mostly just comments that have been changed. Some references to PuSH <0.4 are left because they actually refer to PuSH 0.3 and that's not WebSub... The only actual code change that might affect anything is FeedSub->isPuSH() but the only official plugin using that call was FeedPoller anyway...
This commit is contained in:
parent
b3da5bdaa3
commit
f4d6710a0f
|
@ -147,7 +147,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
||||||
*
|
*
|
||||||
* This will handle just about all events where an activity
|
* This will handle just about all events where an activity
|
||||||
* object gets saved, whether it is via AtomPub, OStatus
|
* object gets saved, whether it is via AtomPub, OStatus
|
||||||
* (PuSH and Salmon transports), or ActivityStreams-based
|
* (WebSub and Salmon transports), or ActivityStreams-based
|
||||||
* backup/restore of account data.
|
* backup/restore of account data.
|
||||||
*
|
*
|
||||||
* You should be able to accept as input the output from an
|
* You should be able to accept as input the output from an
|
||||||
|
@ -193,7 +193,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
||||||
*
|
*
|
||||||
* This will be how your specialized notice gets output in
|
* This will be how your specialized notice gets output in
|
||||||
* Atom feeds and JSON-based ActivityStreams output, including
|
* Atom feeds and JSON-based ActivityStreams output, including
|
||||||
* account backup/restore and OStatus (PuSH and Salmon transports).
|
* account backup/restore and OStatus (WebSub and Salmon transports).
|
||||||
*
|
*
|
||||||
* You should be able to round-trip data from this format back
|
* You should be able to round-trip data from this format back
|
||||||
* through $this->saveNoticeFromActivity(). Where applicable, try
|
* through $this->saveNoticeFromActivity(). Where applicable, try
|
||||||
|
@ -324,7 +324,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a posted object from PuSH
|
* Handle a posted object from WebSub
|
||||||
*
|
*
|
||||||
* @param Activity $activity activity to handle
|
* @param Activity $activity activity to handle
|
||||||
* @param Profile $actor Profile for the feed
|
* @param Profile $actor Profile for the feed
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* GNU social feed polling plugin, to avoid using external PuSH hubs
|
* GNU social feed polling plugin, to avoid using external WebSub hubs
|
||||||
*
|
*
|
||||||
* @category Feed
|
* @category Feed
|
||||||
* @package GNUsocial
|
* @package GNUsocial
|
||||||
|
@ -30,7 +30,7 @@ class FeedPollerPlugin extends Plugin {
|
||||||
|
|
||||||
public function onFeedSubscribe(FeedSub $feedsub)
|
public function onFeedSubscribe(FeedSub $feedsub)
|
||||||
{
|
{
|
||||||
if (!$feedsub->isPuSH()) {
|
if (!$feedsub->isWebSub()) {
|
||||||
FeedPoll::setupFeedSub($feedsub, $this->interval*60);
|
FeedPoll::setupFeedSub($feedsub, $this->interval*60);
|
||||||
return false; // We're polling this feed, so stop processing FeedSubscribe
|
return false; // We're polling this feed, so stop processing FeedSubscribe
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class FeedPollerPlugin extends Plugin {
|
||||||
|
|
||||||
public function onFeedUnsubscribe(FeedSub $feedsub)
|
public function onFeedUnsubscribe(FeedSub $feedsub)
|
||||||
{
|
{
|
||||||
if (!$feedsub->isPuSH()) {
|
if (!$feedsub->isWebSub()) {
|
||||||
// removes sub_state setting and such
|
// removes sub_state setting and such
|
||||||
$feedsub->confirmUnsubscribe();
|
$feedsub->confirmUnsubscribe();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
The FeedPoller plugin allows users to subscribe to non-PuSH-enabled feeds
|
The FeedPoller plugin allows users to subscribe to non-WebSub-enabled feeds
|
||||||
by regularly polling the source for new content.
|
by regularly polling the source for new content.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
|
|
@ -22,7 +22,7 @@ class FeedPollQueueHandler extends QueueHandler
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!$feedsub->sub_state == 'nohub') {
|
if (!$feedsub->sub_state == 'nohub') {
|
||||||
// We're not supposed to poll this (either it's PuSH or it's unsubscribed)
|
// We're not supposed to poll this (either it's WebSub or it's unsubscribed)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ if (!$feedsub instanceof FeedSub) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($feedsub->sub_state != 'nohub') {
|
if ($feedsub->sub_state != 'nohub') {
|
||||||
echo "Feed is a PuSH feed, so we will not poll it.\n";
|
echo "Feed is a WebSub feed, so we will not poll it.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class OStatusPlugin extends Plugin
|
||||||
$m->connect('main/ostatuspeopletag',
|
$m->connect('main/ostatuspeopletag',
|
||||||
array('action' => 'ostatuspeopletag'));
|
array('action' => 'ostatuspeopletag'));
|
||||||
|
|
||||||
// PuSH actions
|
// WebSub actions
|
||||||
$m->connect('main/push/hub', array('action' => 'pushhub'));
|
$m->connect('main/push/hub', array('action' => 'pushhub'));
|
||||||
|
|
||||||
$m->connect('main/push/callback/:feed',
|
$m->connect('main/push/callback/:feed',
|
||||||
|
@ -91,7 +91,7 @@ class OStatusPlugin extends Plugin
|
||||||
// Prepare outgoing distributions after notice save.
|
// Prepare outgoing distributions after notice save.
|
||||||
$qm->connect('ostatus', 'OStatusQueueHandler');
|
$qm->connect('ostatus', 'OStatusQueueHandler');
|
||||||
|
|
||||||
// Outgoing from our internal PuSH hub
|
// Outgoing from our internal WebSub hub
|
||||||
$qm->connect('hubconf', 'HubConfQueueHandler');
|
$qm->connect('hubconf', 'HubConfQueueHandler');
|
||||||
$qm->connect('hubprep', 'HubPrepQueueHandler');
|
$qm->connect('hubprep', 'HubPrepQueueHandler');
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class OStatusPlugin extends Plugin
|
||||||
// Outgoing Salmon replies (when we don't need a return value)
|
// Outgoing Salmon replies (when we don't need a return value)
|
||||||
$qm->connect('salmon', 'SalmonQueueHandler');
|
$qm->connect('salmon', 'SalmonQueueHandler');
|
||||||
|
|
||||||
// Incoming from a foreign PuSH hub
|
// Incoming from a foreign WebSub hub
|
||||||
$qm->connect('pushin', 'PushInQueueHandler');
|
$qm->connect('pushin', 'PushInQueueHandler');
|
||||||
|
|
||||||
// Re-subscribe feeds that need renewal
|
// Re-subscribe feeds that need renewal
|
||||||
|
@ -126,7 +126,7 @@ class OStatusPlugin extends Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up a PuSH hub link to our internal link for canonical timeline
|
* Set up a WebSub hub link to our internal link for canonical timeline
|
||||||
* Atom feeds for users and groups.
|
* Atom feeds for users and groups.
|
||||||
*/
|
*/
|
||||||
function onStartApiAtom($feed)
|
function onStartApiAtom($feed)
|
||||||
|
@ -153,7 +153,7 @@ class OStatusPlugin extends Plugin
|
||||||
if (!empty($id)) {
|
if (!empty($id)) {
|
||||||
$hub = common_config('ostatus', 'hub');
|
$hub = common_config('ostatus', 'hub');
|
||||||
if (empty($hub)) {
|
if (empty($hub)) {
|
||||||
// Updates will be handled through our internal PuSH hub.
|
// Updates will be handled through our internal WebSub hub.
|
||||||
$hub = common_local_url('pushhub');
|
$hub = common_local_url('pushhub');
|
||||||
}
|
}
|
||||||
$feed->addLink($hub, array('rel' => 'hub'));
|
$feed->addLink($hub, array('rel' => 'hub'));
|
||||||
|
@ -547,7 +547,7 @@ class OStatusPlugin extends Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send incoming PuSH feeds for OStatus endpoints in for processing.
|
* Send incoming WebSub feeds for OStatus endpoints in for processing.
|
||||||
*
|
*
|
||||||
* @param FeedSub $feedsub
|
* @param FeedSub $feedsub
|
||||||
* @param DOMDocument $feed
|
* @param DOMDocument $feed
|
||||||
|
@ -583,10 +583,10 @@ class OStatusPlugin extends Plugin
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When about to subscribe to a remote user, start a server-to-server
|
* When about to subscribe to a remote user, start a server-to-server
|
||||||
* PuSH subscription if needed. If we can't establish that, abort.
|
* WebSub subscription if needed. If we can't establish that, abort.
|
||||||
*
|
*
|
||||||
* @fixme If something else aborts later, we could end up with a stray
|
* @fixme If something else aborts later, we could end up with a stray
|
||||||
* PuSH subscription. This is relatively harmless, though.
|
* WebSub subscription. This is relatively harmless, though.
|
||||||
*
|
*
|
||||||
* @param Profile $profile subscriber
|
* @param Profile $profile subscriber
|
||||||
* @param Profile $other subscribee
|
* @param Profile $other subscribee
|
||||||
|
@ -660,7 +660,7 @@ class OStatusPlugin extends Plugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop the PuSH subscription if there are no other subscribers.
|
// Drop the WebSub subscription if there are no other subscribers.
|
||||||
$oprofile->garbageCollect();
|
$oprofile->garbageCollect();
|
||||||
|
|
||||||
$act = new Activity();
|
$act = new Activity();
|
||||||
|
@ -761,7 +761,7 @@ class OStatusPlugin extends Plugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop the PuSH subscription if there are no other subscribers.
|
// Drop the WebSub subscription if there are no other subscribers.
|
||||||
$oprofile->garbageCollect();
|
$oprofile->garbageCollect();
|
||||||
|
|
||||||
$member = $profile;
|
$member = $profile;
|
||||||
|
@ -858,7 +858,7 @@ class OStatusPlugin extends Plugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop the PuSH subscription if there are no other subscribers.
|
// Drop the WebSub subscription if there are no other subscribers.
|
||||||
$oprofile->garbageCollect();
|
$oprofile->garbageCollect();
|
||||||
|
|
||||||
$sub = Profile::getKV($user->id);
|
$sub = Profile::getKV($user->id);
|
||||||
|
@ -969,7 +969,7 @@ class OStatusPlugin extends Plugin
|
||||||
|
|
||||||
$oprofile->notifyDeferred($act, $tagger);
|
$oprofile->notifyDeferred($act, $tagger);
|
||||||
|
|
||||||
// initiate a PuSH subscription for the person being tagged
|
// initiate a WebSub subscription for the person being tagged
|
||||||
$oprofile->subscribe();
|
$oprofile->subscribe();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1020,7 +1020,7 @@ class OStatusPlugin extends Plugin
|
||||||
|
|
||||||
$oprofile->notifyDeferred($act, $tagger);
|
$oprofile->notifyDeferred($act, $tagger);
|
||||||
|
|
||||||
// unsubscribe to PuSH feed if no more required
|
// unsubscribe to WebSub feed if no more required
|
||||||
$oprofile->garbageCollect();
|
$oprofile->garbageCollect();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1155,7 +1155,7 @@ class OStatusPlugin extends Plugin
|
||||||
|
|
||||||
// Find foreign accounts I'm subscribed to that support Salmon pings.
|
// Find foreign accounts I'm subscribed to that support Salmon pings.
|
||||||
//
|
//
|
||||||
// @fixme we could run updates through the PuSH feed too,
|
// @fixme we could run updates through the WebSub feed too,
|
||||||
// in which case we can skip Salmon pings to folks who
|
// in which case we can skip Salmon pings to folks who
|
||||||
// are also subscribed to me.
|
// are also subscribed to me.
|
||||||
$sql = "SELECT * FROM ostatus_profile " .
|
$sql = "SELECT * FROM ostatus_profile " .
|
||||||
|
|
|
@ -3,26 +3,27 @@ The OStatus plugin concentrates on user-to-user cases for federating StatusNet
|
||||||
and similar social networking / microblogging / blogging sites, but includes
|
and similar social networking / microblogging / blogging sites, but includes
|
||||||
low-level feed subscription systems which are used by some other plugins.
|
low-level feed subscription systems which are used by some other plugins.
|
||||||
|
|
||||||
Uses PubSubHubbub for push feed updates; currently non-PuSH feeds cannot be
|
Uses WebSub (previously named PubSubHubbub or PuSH) for push feed updates;
|
||||||
subscribed unless an external PuSH hub proxy is used.
|
currently non-WebSub feeds cannot be subscribed unless an external
|
||||||
|
WebSub hub proxy is used.
|
||||||
|
|
||||||
|
|
||||||
Configuration options available:
|
Configuration options available:
|
||||||
|
|
||||||
$config['ostatus']['hub']
|
$config['ostatus']['hub']
|
||||||
(default internal hub)
|
(default internal hub)
|
||||||
Set to URL of an external PuSH hub to use it instead of our internal hub
|
Set to URL of an external WebSub hub to use it instead of our internal hub
|
||||||
for sending outgoing updates in user and group feeds.
|
for sending outgoing updates in user and group feeds.
|
||||||
|
|
||||||
$config['ostatus']['hub_retries']
|
$config['ostatus']['hub_retries']
|
||||||
(default 0)
|
(default 0)
|
||||||
Number of times to retry a PuSH send to consumers if using internal hub
|
Number of times to retry a WebSub send to consumers if using internal hub
|
||||||
|
|
||||||
|
|
||||||
Settings controlling incoming feed subscription:
|
Settings controlling incoming feed subscription:
|
||||||
|
|
||||||
$config['feedsub']['fallback_hub']
|
$config['feedsub']['fallback_hub']
|
||||||
To subscribe to feeds that don't have a hub, an external PuSH proxy hub
|
To subscribe to feeds that don't have a hub, an external WebSub proxy hub
|
||||||
such as Superfeedr may be used. Any feed without a hub of its own will
|
such as Superfeedr may be used. Any feed without a hub of its own will
|
||||||
be subscribed through the specified hub URL instead. If the external hub
|
be subscribed through the specified hub URL instead. If the external hub
|
||||||
has usage charges, be aware that there is no restriction placed to how
|
has usage charges, be aware that there is no restriction placed to how
|
||||||
|
|
|
@ -54,7 +54,7 @@ class PushCallbackAction extends Action
|
||||||
$feedsub = FeedSub::getKV('id', $feedid);
|
$feedsub = FeedSub::getKV('id', $feedid);
|
||||||
if (!$feedsub instanceof FeedSub) {
|
if (!$feedsub instanceof FeedSub) {
|
||||||
// TRANS: Server exception. %s is a feed ID.
|
// TRANS: Server exception. %s is a feed ID.
|
||||||
throw new ServerException(sprintf(_m('Unknown PuSH feed id %s'),$feedid), 400);
|
throw new ServerException(sprintf(_m('Unknown WebSub subscription feed id %s'),$feedid), 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$hmac = '';
|
$hmac = '';
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integrated PuSH hub; lets us only ping them what need it.
|
* Integrated WebSub hub; lets us only ping them what need it.
|
||||||
* @package Hub
|
* @package Hub
|
||||||
* @maintainer Brion Vibber <brion@status.net>
|
* @maintainer Brion Vibber <brion@status.net>
|
||||||
*/
|
*/
|
||||||
|
@ -71,7 +71,7 @@ class PushHubAction extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a request for a new or modified PuSH feed subscription.
|
* Process a request for a new or modified WebSub feed subscription.
|
||||||
* If asynchronous verification is requested, updates won't be saved immediately.
|
* If asynchronous verification is requested, updates won't be saved immediately.
|
||||||
*
|
*
|
||||||
* HTTP return codes:
|
* HTTP return codes:
|
||||||
|
@ -83,24 +83,24 @@ class PushHubAction extends Action
|
||||||
{
|
{
|
||||||
$callback = $this->argUrl('hub.callback');
|
$callback = $this->argUrl('hub.callback');
|
||||||
|
|
||||||
common_debug('New PuSH hub request ('._ve($mode).') for callback '._ve($callback));
|
common_debug('New WebSub hub request ('._ve($mode).') for callback '._ve($callback));
|
||||||
$topic = $this->argUrl('hub.topic');
|
$topic = $this->argUrl('hub.topic');
|
||||||
if (!$this->recognizedFeed($topic)) {
|
if (!$this->recognizedFeed($topic)) {
|
||||||
common_debug('PuSH hub request had unrecognized feed topic=='._ve($topic));
|
common_debug('WebSub hub request had unrecognized feed topic=='._ve($topic));
|
||||||
// TRANS: Client exception. %s is a topic.
|
// TRANS: Client exception. %s is a topic.
|
||||||
throw new ClientException(sprintf(_m('Unsupported hub.topic %s this hub only serves local user and group Atom feeds.'),$topic));
|
throw new ClientException(sprintf(_m('Unsupported hub.topic %s this hub only serves local user and group Atom feeds.'),$topic));
|
||||||
}
|
}
|
||||||
|
|
||||||
$lease = $this->arg('hub.lease_seconds', null);
|
$lease = $this->arg('hub.lease_seconds', null);
|
||||||
if ($mode == 'subscribe' && $lease != '' && !preg_match('/^\d+$/', $lease)) {
|
if ($mode == 'subscribe' && $lease != '' && !preg_match('/^\d+$/', $lease)) {
|
||||||
common_debug('PuSH hub request had invalid lease_seconds=='._ve($lease));
|
common_debug('WebSub hub request had invalid lease_seconds=='._ve($lease));
|
||||||
// TRANS: Client exception. %s is the invalid lease value.
|
// TRANS: Client exception. %s is the invalid lease value.
|
||||||
throw new ClientException(sprintf(_m('Invalid hub.lease "%s". It must be empty or positive integer.'),$lease));
|
throw new ClientException(sprintf(_m('Invalid hub.lease "%s". It must be empty or positive integer.'),$lease));
|
||||||
}
|
}
|
||||||
|
|
||||||
$secret = $this->arg('hub.secret', null);
|
$secret = $this->arg('hub.secret', null);
|
||||||
if ($secret != '' && strlen($secret) >= 200) {
|
if ($secret != '' && strlen($secret) >= 200) {
|
||||||
common_debug('PuSH hub request had invalid secret=='._ve($secret));
|
common_debug('WebSub hub request had invalid secret=='._ve($secret));
|
||||||
// TRANS: Client exception. %s is the invalid hub secret.
|
// TRANS: Client exception. %s is the invalid hub secret.
|
||||||
throw new ClientException(sprintf(_m('Invalid hub.secret "%s". It must be under 200 bytes.'),$secret));
|
throw new ClientException(sprintf(_m('Invalid hub.secret "%s". It must be under 200 bytes.'),$secret));
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class PushHubAction extends Action
|
||||||
$sub = HubSub::getByHashkey($topic, $callback);
|
$sub = HubSub::getByHashkey($topic, $callback);
|
||||||
if (!$sub instanceof HubSub) {
|
if (!$sub instanceof HubSub) {
|
||||||
// Creating a new one!
|
// Creating a new one!
|
||||||
common_debug('PuSH creating new HubSub entry for topic=='._ve($topic).' to remote callback '._ve($callback));
|
common_debug('WebSub creating new HubSub entry for topic=='._ve($topic).' to remote callback '._ve($callback));
|
||||||
$sub = new HubSub();
|
$sub = new HubSub();
|
||||||
$sub->topic = $topic;
|
$sub->topic = $topic;
|
||||||
$sub->callback = $callback;
|
$sub->callback = $callback;
|
||||||
|
@ -121,15 +121,15 @@ class PushHubAction extends Action
|
||||||
$sub->setLease(intval($lease));
|
$sub->setLease(intval($lease));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
common_debug('PuSH hub request is now:'._ve($sub));
|
common_debug('WebSub hub request is now:'._ve($sub));
|
||||||
|
|
||||||
$verify = $this->arg('hub.verify'); // TODO: deprecated
|
$verify = $this->arg('hub.verify'); // TODO: deprecated
|
||||||
$token = $this->arg('hub.verify_token', null); // TODO: deprecated
|
$token = $this->arg('hub.verify_token', null); // TODO: deprecated
|
||||||
if ($verify == 'sync') { // pre-0.4 PuSH
|
if ($verify == 'sync') { // pre-0.4 PuSH
|
||||||
$sub->verify($mode, $token);
|
$sub->verify($mode, $token);
|
||||||
header('HTTP/1.1 204 No Content');
|
header('HTTP/1.1 204 No Content');
|
||||||
} else { // If $verify is not "sync", we might be using PuSH 0.4
|
} else { // If $verify is not "sync", we might be using WebSub or PuSH 0.4
|
||||||
$sub->scheduleVerify($mode, $token); // If we were certain it's PuSH 0.4, token could be removed
|
$sub->scheduleVerify($mode, $token); // If we were certain it's WebSub or PuSH 0.4, token could be removed
|
||||||
header('HTTP/1.1 202 Accepted');
|
header('HTTP/1.1 202 Accepted');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PuSH subscription flow:
|
WebSub (previously PubSubHubbub/PuSH) subscription flow:
|
||||||
|
|
||||||
$profile->subscribe()
|
$profile->subscribe()
|
||||||
sends a sub request to the hub...
|
sends a sub request to the hub...
|
||||||
|
@ -41,7 +41,7 @@ PuSH subscription flow:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FeedSub handles low-level PubHubSubbub (PuSH) subscriptions.
|
* FeedSub handles low-level WebSub (PubSubHubbub/PuSH) subscriptions.
|
||||||
* Higher-level behavior building OStatus stuff on top is handled
|
* Higher-level behavior building OStatus stuff on top is handled
|
||||||
* under Ostatus_profile.
|
* under Ostatus_profile.
|
||||||
*/
|
*/
|
||||||
|
@ -52,7 +52,7 @@ class FeedSub extends Managed_DataObject
|
||||||
public $id;
|
public $id;
|
||||||
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
|
||||||
|
|
||||||
// PuSH subscription data
|
// WebSub subscription data
|
||||||
public $huburi;
|
public $huburi;
|
||||||
public $secret;
|
public $secret;
|
||||||
public $sub_state; // subscribe, active, unsubscribe, inactive, nohub
|
public $sub_state; // subscribe, active, unsubscribe, inactive, nohub
|
||||||
|
@ -105,14 +105,15 @@ class FeedSub extends Managed_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do we have a hub? Then we are a PuSH feed.
|
* Do we have a hub? Then we are a WebSub feed.
|
||||||
* https://en.wikipedia.org/wiki/PubSubHubbub
|
* WebSub standard: https://www.w3.org/TR/websub/
|
||||||
|
* old: https://en.wikipedia.org/wiki/PubSubHubbub
|
||||||
*
|
*
|
||||||
* If huburi is empty, then doublecheck that we are not using
|
* If huburi is empty, then doublecheck that we are not using
|
||||||
* a fallback hub. If there is a fallback hub, it is only if the
|
* a fallback hub. If there is a fallback hub, it is only if the
|
||||||
* sub_state is "nohub" that we assume it's not a PuSH feed.
|
* sub_state is "nohub" that we assume it's not a WebSub feed.
|
||||||
*/
|
*/
|
||||||
public function isPuSH()
|
public function isWebSub()
|
||||||
{
|
{
|
||||||
if (empty($this->huburi)
|
if (empty($this->huburi)
|
||||||
&& (!common_config('feedsub', 'fallback_hub')
|
&& (!common_config('feedsub', 'fallback_hub')
|
||||||
|
@ -151,7 +152,7 @@ class FeedSub extends Managed_DataObject
|
||||||
/**
|
/**
|
||||||
* @param string $feeduri
|
* @param string $feeduri
|
||||||
* @return FeedSub
|
* @return FeedSub
|
||||||
* @throws FeedSubException if feed is invalid or lacks PuSH setup
|
* @throws FeedSubException if feed is invalid or lacks WebSub setup
|
||||||
*/
|
*/
|
||||||
public static function ensureFeed($feeduri)
|
public static function ensureFeed($feeduri)
|
||||||
{
|
{
|
||||||
|
@ -262,7 +263,7 @@ class FeedSub extends Managed_DataObject
|
||||||
public function subscribe()
|
public function subscribe()
|
||||||
{
|
{
|
||||||
if ($this->sub_state && $this->sub_state != 'inactive') {
|
if ($this->sub_state && $this->sub_state != 'inactive') {
|
||||||
common_log(LOG_WARNING, sprintf('Attempting to (re)start PuSH subscription to %s in unexpected state %s', $this->getUri(), $this->sub_state));
|
common_log(LOG_WARNING, sprintf('Attempting to (re)start WebSub subscription to %s in unexpected state %s', $this->getUri(), $this->sub_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Event::handle('FeedSubscribe', array($this))) {
|
if (!Event::handle('FeedSubscribe', array($this))) {
|
||||||
|
@ -280,7 +281,7 @@ class FeedSub extends Managed_DataObject
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// TRANS: Server exception.
|
// TRANS: Server exception.
|
||||||
throw new ServerException(_m('Attempting to start PuSH subscription for feed with no hub.'));
|
throw new ServerException(_m('Attempting to start WebSub subscription for feed with no hub.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +289,7 @@ class FeedSub extends Managed_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a PuSH unsubscription request to the hub for this feed.
|
* Send a WebSub unsubscription request to the hub for this feed.
|
||||||
* The hub will later send us a confirmation POST to /main/push/callback.
|
* The hub will later send us a confirmation POST to /main/push/callback.
|
||||||
* Warning: this will cancel the subscription even if someone else in
|
* Warning: this will cancel the subscription even if someone else in
|
||||||
* the system is using it. Most callers will want garbageCollect() instead,
|
* the system is using it. Most callers will want garbageCollect() instead,
|
||||||
|
@ -298,7 +299,7 @@ class FeedSub extends Managed_DataObject
|
||||||
*/
|
*/
|
||||||
public function unsubscribe() {
|
public function unsubscribe() {
|
||||||
if ($this->sub_state != 'active') {
|
if ($this->sub_state != 'active') {
|
||||||
common_log(LOG_WARNING, sprintf('Attempting to (re)end PuSH subscription to %s in unexpected state %s', $this->getUri(), $this->sub_state));
|
common_log(LOG_WARNING, sprintf('Attempting to (re)end WebSub subscription to %s in unexpected state %s', $this->getUri(), $this->sub_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Event::handle('FeedUnsubscribe', array($this))) {
|
if (!Event::handle('FeedUnsubscribe', array($this))) {
|
||||||
|
@ -314,7 +315,7 @@ class FeedSub extends Managed_DataObject
|
||||||
* A plugin should handle the FeedSub above and set the proper state
|
* A plugin should handle the FeedSub above and set the proper state
|
||||||
* if there is no hub. (instead of 'nohub' it should be 'inactive' if
|
* if there is no hub. (instead of 'nohub' it should be 'inactive' if
|
||||||
* the instance has enabled feed polling for feeds that don't publish
|
* the instance has enabled feed polling for feeds that don't publish
|
||||||
* PuSH/WebSub hubs. FeedPoller is a plugin which enables polling.
|
* WebSub/PuSH hubs. FeedPoller is a plugin which enables polling.
|
||||||
*
|
*
|
||||||
* Secondly, if we don't have the setting "nohub" enabled (i.e.)
|
* Secondly, if we don't have the setting "nohub" enabled (i.e.)
|
||||||
* we're ready to poll ourselves, there is something odd with the
|
* we're ready to poll ourselves, there is something odd with the
|
||||||
|
@ -323,7 +324,7 @@ class FeedSub extends Managed_DataObject
|
||||||
|
|
||||||
if (!common_config('feedsub', 'nohub')) {
|
if (!common_config('feedsub', 'nohub')) {
|
||||||
// TRANS: Server exception.
|
// TRANS: Server exception.
|
||||||
throw new ServerException(_m('Attempting to end PuSH subscription for feed with no hub.'));
|
throw new ServerException(_m('Attempting to end WebSub subscription for feed with no hub.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -343,11 +344,11 @@ class FeedSub extends Managed_DataObject
|
||||||
public function garbageCollect()
|
public function garbageCollect()
|
||||||
{
|
{
|
||||||
if ($this->sub_state == '' || $this->sub_state == 'inactive') {
|
if ($this->sub_state == '' || $this->sub_state == 'inactive') {
|
||||||
// No active PuSH subscription, we can just leave it be.
|
// No active WebSub subscription, we can just leave it be.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PuSH subscription is either active or in an indeterminate state.
|
// WebSub subscription is either active or in an indeterminate state.
|
||||||
// Check if we're out of subscribers, and if so send an unsubscribe.
|
// Check if we're out of subscribers, and if so send an unsubscribe.
|
||||||
$count = 0;
|
$count = 0;
|
||||||
Event::handle('FeedSubSubscriberCount', array($this, &$count));
|
Event::handle('FeedSubSubscriberCount', array($this, &$count));
|
||||||
|
@ -426,12 +427,12 @@ class FeedSub extends Managed_DataObject
|
||||||
$client->setAuth($u, $p);
|
$client->setAuth($u, $p);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new FeedSubException('Server could not find a usable PuSH hub.');
|
throw new FeedSubException('Server could not find a usable WebSub hub.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$response = $client->post($hub, $headers, $post);
|
$response = $client->post($hub, $headers, $post);
|
||||||
$status = $response->getStatus();
|
$status = $response->getStatus();
|
||||||
// PuSH specificed response status code
|
// WebSub specificed response status code
|
||||||
if ($status == 202 || $status == 204) {
|
if ($status == 202 || $status == 204) {
|
||||||
common_log(LOG_INFO, __METHOD__ . ': sub req ok, awaiting verification callback');
|
common_log(LOG_INFO, __METHOD__ . ': sub req ok, awaiting verification callback');
|
||||||
return;
|
return;
|
||||||
|
@ -440,7 +441,7 @@ class FeedSub extends Managed_DataObject
|
||||||
$msg = sprintf(_m("Unexpected HTTP status: %d"), $status);
|
$msg = sprintf(_m("Unexpected HTTP status: %d"), $status);
|
||||||
} else if ($status == 422) {
|
} else if ($status == 422) {
|
||||||
// Error code regarding something wrong in the data (it seems
|
// Error code regarding something wrong in the data (it seems
|
||||||
// that we're talking to a PuSH hub at least, so let's check
|
// that we're talking to a WebSub hub at least, so let's check
|
||||||
// our own data to be sure we're not mistaken somehow.
|
// our own data to be sure we're not mistaken somehow.
|
||||||
|
|
||||||
$this->ensureHub(true);
|
$this->ensureHub(true);
|
||||||
|
@ -462,7 +463,7 @@ class FeedSub extends Managed_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save PuSH subscription confirmation.
|
* Save WebSub subscription confirmation.
|
||||||
* Sets approximate lease start and end times and finalizes state.
|
* Sets approximate lease start and end times and finalizes state.
|
||||||
*
|
*
|
||||||
* @param int $lease_seconds provided hub.lease_seconds parameter, if given
|
* @param int $lease_seconds provided hub.lease_seconds parameter, if given
|
||||||
|
@ -485,8 +486,8 @@ class FeedSub extends Managed_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save PuSH unsubscription confirmation.
|
* Save WebSub unsubscription confirmation.
|
||||||
* Wipes active PuSH sub info and resets state.
|
* Wipes active WebSub sub info and resets state.
|
||||||
*/
|
*/
|
||||||
public function confirmUnsubscribe()
|
public function confirmUnsubscribe()
|
||||||
{
|
{
|
||||||
|
@ -503,7 +504,7 @@ class FeedSub extends Managed_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept updates from a PuSH feed. If validated, this object and the
|
* Accept updates from a WebSub feed. If validated, this object and the
|
||||||
* feed (as a DOMDocument) will be passed to the StartFeedSubHandleFeed
|
* feed (as a DOMDocument) will be passed to the StartFeedSubHandleFeed
|
||||||
* and EndFeedSubHandleFeed events for processing.
|
* and EndFeedSubHandleFeed events for processing.
|
||||||
*
|
*
|
||||||
|
@ -521,7 +522,7 @@ class FeedSub extends Managed_DataObject
|
||||||
common_log(LOG_INFO, sprintf(__METHOD__.': packet for %s with HMAC %s', _ve($this->getUri()), _ve($hmac)));
|
common_log(LOG_INFO, sprintf(__METHOD__.': packet for %s with HMAC %s', _ve($this->getUri()), _ve($hmac)));
|
||||||
|
|
||||||
if (!in_array($this->sub_state, array('active', 'nohub'))) {
|
if (!in_array($this->sub_state, array('active', 'nohub'))) {
|
||||||
common_log(LOG_ERR, sprintf(__METHOD__.': ignoring PuSH for inactive feed %s (in state %s)', _ve($this->getUri()), _ve($this->sub_state)));
|
common_log(LOG_ERR, sprintf(__METHOD__.': ignoring WebSub for inactive feed %s (in state %s)', _ve($this->getUri()), _ve($this->sub_state)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,7 +605,7 @@ class FeedSub extends Managed_DataObject
|
||||||
if (preg_match('/^([0-9a-zA-Z\-\,]{3,16})=([0-9a-fA-F]+)$/', $hmac, $matches)) {
|
if (preg_match('/^([0-9a-zA-Z\-\,]{3,16})=([0-9a-fA-F]+)$/', $hmac, $matches)) {
|
||||||
$hash_algo = strtolower($matches[1]);
|
$hash_algo = strtolower($matches[1]);
|
||||||
$their_hmac = strtolower($matches[2]);
|
$their_hmac = strtolower($matches[2]);
|
||||||
common_debug(sprintf(__METHOD__ . ': PuSH from feed %s uses HMAC algorithm %s with value: %s', _ve($this->getUri()), _ve($hash_algo), _ve($their_hmac)));
|
common_debug(sprintf(__METHOD__ . ': WebSub push from feed %s uses HMAC algorithm %s with value: %s', _ve($this->getUri()), _ve($hash_algo), _ve($their_hmac)));
|
||||||
|
|
||||||
if (!in_array($hash_algo, hash_algos())) {
|
if (!in_array($hash_algo, hash_algos())) {
|
||||||
// We can't handle this at all, PHP doesn't recognize the algorithm name ('md5', 'sha1', 'sha256' etc: https://secure.php.net/manual/en/function.hash-algos.php)
|
// We can't handle this at all, PHP doesn't recognize the algorithm name ('md5', 'sha1', 'sha256' etc: https://secure.php.net/manual/en/function.hash-algos.php)
|
||||||
|
@ -618,19 +619,19 @@ class FeedSub extends Managed_DataObject
|
||||||
|
|
||||||
$our_hmac = hash_hmac($hash_algo, $post, $this->secret);
|
$our_hmac = hash_hmac($hash_algo, $post, $this->secret);
|
||||||
if ($their_hmac !== $our_hmac) {
|
if ($their_hmac !== $our_hmac) {
|
||||||
common_log(LOG_ERR, sprintf(__METHOD__.': ignoring PuSH with bad HMAC hash: got %s, expected %s for feed %s from hub %s', _ve($their_hmac), _ve($our_hmac), _ve($this->getUri()), _ve($this->huburi)));
|
common_log(LOG_ERR, sprintf(__METHOD__.': ignoring WebSub push with bad HMAC hash: got %s, expected %s for feed %s from hub %s', _ve($their_hmac), _ve($our_hmac), _ve($this->getUri()), _ve($this->huburi)));
|
||||||
throw new FeedSubBadPushSignatureException('Incoming PuSH signature did not match expected HMAC hash.');
|
throw new FeedSubBadPushSignatureException('Incoming WebSub push signature did not match expected HMAC hash.');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
common_log(LOG_ERR, sprintf(__METHOD__.': ignoring PuSH with bogus HMAC==', _ve($hmac)));
|
common_log(LOG_ERR, sprintf(__METHOD__.': ignoring WebSub push with bogus HMAC==', _ve($hmac)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (empty($hmac)) {
|
if (empty($hmac)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
common_log(LOG_ERR, sprintf(__METHOD__.': ignoring PuSH with unexpected HMAC==%s', _ve($hmac)));
|
common_log(LOG_ERR, sprintf(__METHOD__.': ignoring WebSub push with unexpected HMAC==%s', _ve($hmac)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PuSH feed subscription record
|
* WebSub (previously PuSH) feed subscription record
|
||||||
* @package Hub
|
* @package Hub
|
||||||
* @author Brion Vibber <brion@status.net>
|
* @author Brion Vibber <brion@status.net>
|
||||||
*/
|
*/
|
||||||
|
@ -78,7 +78,7 @@ class HubSub extends Managed_DataObject
|
||||||
*/
|
*/
|
||||||
function setLease($length)
|
function setLease($length)
|
||||||
{
|
{
|
||||||
common_debug('PuSH hub got requested lease_seconds=='._ve($length));
|
common_debug('WebSub hub got requested lease_seconds=='._ve($length));
|
||||||
assert(is_int($length));
|
assert(is_int($length));
|
||||||
|
|
||||||
$min = 86400; // 3600*24 (one day)
|
$min = 86400; // 3600*24 (one day)
|
||||||
|
@ -93,7 +93,7 @@ class HubSub extends Managed_DataObject
|
||||||
$length = $max;
|
$length = $max;
|
||||||
}
|
}
|
||||||
|
|
||||||
common_debug('PuSH hub after sanitation: lease_seconds=='._ve($length));
|
common_debug('WebSub hub after sanitation: lease_seconds=='._ve($length));
|
||||||
$this->sub_start = common_sql_now();
|
$this->sub_start = common_sql_now();
|
||||||
$this->sub_end = common_sql_date(time() + $length);
|
$this->sub_end = common_sql_date(time() + $length);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ class HubSub extends Managed_DataObject
|
||||||
$data = array('sub' => $sub,
|
$data = array('sub' => $sub,
|
||||||
'atom' => $atom,
|
'atom' => $atom,
|
||||||
'retries' => $retries);
|
'retries' => $retries);
|
||||||
common_log(LOG_INFO, "Queuing PuSH: {$this->getTopic()} to {$this->callback}");
|
common_log(LOG_INFO, "Queuing WebSub: {$this->getTopic()} to {$this->callback}");
|
||||||
$qm = QueueManager::get();
|
$qm = QueueManager::get();
|
||||||
$qm->enqueue($data, 'hubout');
|
$qm->enqueue($data, 'hubout');
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ class HubSub extends Managed_DataObject
|
||||||
$data = array('atom' => $atom,
|
$data = array('atom' => $atom,
|
||||||
'topic' => $this->getTopic(),
|
'topic' => $this->getTopic(),
|
||||||
'pushCallbacks' => $pushCallbacks);
|
'pushCallbacks' => $pushCallbacks);
|
||||||
common_log(LOG_INFO, "Queuing PuSH batch: {$this->getTopic()} to ".count($pushCallbacks)." sites");
|
common_log(LOG_INFO, "Queuing WebSub batch: {$this->getTopic()} to ".count($pushCallbacks)." sites");
|
||||||
$qm = QueueManager::get();
|
$qm = QueueManager::get();
|
||||||
$qm->enqueue($data, 'hubprep');
|
$qm->enqueue($data, 'hubprep');
|
||||||
return true;
|
return true;
|
||||||
|
@ -304,7 +304,7 @@ class HubSub extends Managed_DataObject
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$response = null;
|
$response = null;
|
||||||
|
|
||||||
common_debug('PuSH callback to '._ve($this->callback).' for '._ve($this->getTopic()).' failed with exception: '._ve($e->getMessage()));
|
common_debug('WebSub callback to '._ve($this->callback).' for '._ve($this->getTopic()).' failed with exception: '._ve($e->getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: DO NOT trust a Location header here, _especially_ from 'http' protocols,
|
// XXX: DO NOT trust a Location header here, _especially_ from 'http' protocols,
|
||||||
|
@ -312,9 +312,9 @@ class HubSub extends Managed_DataObject
|
||||||
// the most common change here is simply switching 'http' to 'https' and we will
|
// the most common change here is simply switching 'http' to 'https' and we will
|
||||||
// solve 99% of all of these issues for now. There should be a proper mechanism
|
// solve 99% of all of these issues for now. There should be a proper mechanism
|
||||||
// if we want to change the callback URLs, preferrably just manual resubscriptions
|
// if we want to change the callback URLs, preferrably just manual resubscriptions
|
||||||
// from the remote side, combined with implemented PuSH subscription timeouts.
|
// from the remote side, combined with implemented WebSub subscription timeouts.
|
||||||
|
|
||||||
// We failed the PuSH, but it might be that the remote site has changed their configuration to HTTPS
|
// We failed the WebSub, but it might be that the remote site has changed their configuration to HTTPS
|
||||||
if ('http' === parse_url($this->callback, PHP_URL_SCHEME)) {
|
if ('http' === parse_url($this->callback, PHP_URL_SCHEME)) {
|
||||||
// Test if the feed callback for this node has migrated to HTTPS
|
// Test if the feed callback for this node has migrated to HTTPS
|
||||||
$httpscallback = preg_replace('/^http/', 'https', $this->callback, 1);
|
$httpscallback = preg_replace('/^http/', 'https', $this->callback, 1);
|
||||||
|
@ -324,7 +324,7 @@ class HubSub extends Managed_DataObject
|
||||||
throw new AlreadyFulfilledException('The remote side has already established an HTTPS callback, deleting the legacy HTTP entry.');
|
throw new AlreadyFulfilledException('The remote side has already established an HTTPS callback, deleting the legacy HTTP entry.');
|
||||||
}
|
}
|
||||||
|
|
||||||
common_debug('PuSH callback to '._ve($this->callback).' for '._ve($this->getTopic()).' trying HTTPS callback: '._ve($httpscallback));
|
common_debug('WebSub callback to '._ve($this->callback).' for '._ve($this->getTopic()).' trying HTTPS callback: '._ve($httpscallback));
|
||||||
$response = $request->post($httpscallback, $headers);
|
$response = $request->post($httpscallback, $headers);
|
||||||
if ($response->isOk()) {
|
if ($response->isOk()) {
|
||||||
$orig = clone($this);
|
$orig = clone($this);
|
||||||
|
|
|
@ -239,7 +239,7 @@ class Ostatus_profile extends Managed_DataObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this remote profile has any active local subscriptions, and
|
* Check if this remote profile has any active local subscriptions, and
|
||||||
* if not drop the PuSH subscription feed.
|
* if not drop the WebSub subscription feed.
|
||||||
*
|
*
|
||||||
* @return boolean true if subscription is removed, false if there are still subscribers to the feed
|
* @return boolean true if subscription is removed, false if there are still subscribers to the feed
|
||||||
* @throws Exception of various kinds on failure.
|
* @throws Exception of various kinds on failure.
|
||||||
|
@ -250,7 +250,7 @@ class Ostatus_profile extends Managed_DataObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this remote profile has any active local subscriptions, and
|
* Check if this remote profile has any active local subscriptions, and
|
||||||
* if not drop the PuSH subscription feed.
|
* if not drop the WebSub subscription feed.
|
||||||
*
|
*
|
||||||
* @return boolean true if subscription is removed, false if there are still subscribers to the feed
|
* @return boolean true if subscription is removed, false if there are still subscribers to the feed
|
||||||
* @throws Exception of various kinds on failure.
|
* @throws Exception of various kinds on failure.
|
||||||
|
@ -267,7 +267,7 @@ class Ostatus_profile extends Managed_DataObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this remote profile has any active local subscriptions, so the
|
* Check if this remote profile has any active local subscriptions, so the
|
||||||
* PuSH subscription layer can decide if it can drop the feed.
|
* WebSub subscription layer can decide if it can drop the feed.
|
||||||
*
|
*
|
||||||
* This gets called via the FeedSubSubscriberCount event when running
|
* This gets called via the FeedSubSubscriberCount event when running
|
||||||
* FeedSub::garbageCollect().
|
* FeedSub::garbageCollect().
|
||||||
|
@ -429,7 +429,7 @@ class Ostatus_profile extends Managed_DataObject
|
||||||
/**
|
/**
|
||||||
* Read and post notices for updates from the feed.
|
* Read and post notices for updates from the feed.
|
||||||
* Currently assumes that all items in the feed are new,
|
* Currently assumes that all items in the feed are new,
|
||||||
* coming from a PuSH hub.
|
* coming from a WebSub hub.
|
||||||
*
|
*
|
||||||
* @param DOMDocument $doc
|
* @param DOMDocument $doc
|
||||||
* @param string $source identifier ("push")
|
* @param string $source identifier ("push")
|
||||||
|
@ -779,7 +779,7 @@ class Ostatus_profile extends Managed_DataObject
|
||||||
$hints['salmon'] = $salmonuri;
|
$hints['salmon'] = $salmonuri;
|
||||||
|
|
||||||
if (!$huburi && !common_config('feedsub', 'fallback_hub') && !common_config('feedsub', 'nohub')) {
|
if (!$huburi && !common_config('feedsub', 'fallback_hub') && !common_config('feedsub', 'nohub')) {
|
||||||
// We can only deal with folks with a PuSH hub
|
// We can only deal with folks with a WebSub hub
|
||||||
// unless we have something similar available locally.
|
// unless we have something similar available locally.
|
||||||
throw new FeedSubNoHubException();
|
throw new FeedSubNoHubException();
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1177,7 @@ class Ostatus_profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$huburi && !common_config('feedsub', 'fallback_hub') && !common_config('feedsub', 'nohub')) {
|
if (!$huburi && !common_config('feedsub', 'fallback_hub') && !common_config('feedsub', 'nohub')) {
|
||||||
// We can only deal with folks with a PuSH hub
|
// We can only deal with folks with a WebSub hub
|
||||||
throw new FeedSubNoHubException();
|
throw new FeedSubNoHubException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ class FeedDiscovery
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the referenced PuSH hub link from an Atom feed.
|
* Get the referenced WebSub hub link from an Atom feed.
|
||||||
*
|
*
|
||||||
* @return mixed string or false
|
* @return mixed string or false
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,7 +22,7 @@ if (!defined('STATUSNET')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a PuSH subscription verification from our internal hub.
|
* Send a WebSub subscription verification from our internal hub.
|
||||||
* @package Hub
|
* @package Hub
|
||||||
* @author Brion Vibber <brion@status.net>
|
* @author Brion Vibber <brion@status.net>
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +46,7 @@ class HubConfQueueHandler extends QueueHandler
|
||||||
try {
|
try {
|
||||||
$sub->verify($mode, $token);
|
$sub->verify($mode, $token);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_ERR, "Failed PuSH $mode verify to $sub->callback for $sub->topic: " .
|
common_log(LOG_ERR, "Failed WebSub $mode verify to $sub->callback for $sub->topic: " .
|
||||||
$e->getMessage());
|
$e->getMessage());
|
||||||
// @fixme schedule retry?
|
// @fixme schedule retry?
|
||||||
// @fixme just kill it?
|
// @fixme just kill it?
|
||||||
|
|
|
@ -22,7 +22,7 @@ if (!defined('STATUSNET')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a raw PuSH atom update from our internal hub.
|
* Send a raw WebSub push atom update from our internal hub.
|
||||||
* @package Hub
|
* @package Hub
|
||||||
* @author Brion Vibber <brion@status.net>
|
* @author Brion Vibber <brion@status.net>
|
||||||
*/
|
*/
|
||||||
|
@ -45,10 +45,10 @@ class HubOutQueueHandler extends QueueHandler
|
||||||
try {
|
try {
|
||||||
$sub->push($atom);
|
$sub->push($atom);
|
||||||
} catch (AlreadyFulfilledException $e) {
|
} catch (AlreadyFulfilledException $e) {
|
||||||
common_log(LOG_INFO, "Failed PuSH to $sub->callback for $sub->topic (".get_class($e)."): " . $e->getMessage());
|
common_log(LOG_INFO, "Failed WebSub push to $sub->callback for $sub->topic (".get_class($e)."): " . $e->getMessage());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$retries--;
|
$retries--;
|
||||||
$msg = "Failed PuSH to $sub->callback for $sub->topic (".get_class($e)."): " . $e->getMessage();
|
$msg = "Failed WebSub push to $sub->callback for $sub->topic (".get_class($e)."): " . $e->getMessage();
|
||||||
if ($retries > 0) {
|
if ($retries > 0) {
|
||||||
common_log(LOG_INFO, "$msg; scheduling for $retries more tries");
|
common_log(LOG_INFO, "$msg; scheduling for $retries more tries");
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ if (!defined('STATUSNET')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When we have a large batch of PuSH consumers, we break the data set
|
* When we have a large batch of WebSub consumers, we break the data set
|
||||||
* into smaller chunks. Enqueue final destinations...
|
* into smaller chunks. Enqueue final destinations...
|
||||||
*
|
*
|
||||||
* @package Hub
|
* @package Hub
|
||||||
|
@ -67,14 +67,14 @@ class HubPrepQueueHandler extends QueueHandler
|
||||||
$callback = array_shift($pushCallbacks);
|
$callback = array_shift($pushCallbacks);
|
||||||
$sub = HubSub::getByHashkey($topic, $callback);
|
$sub = HubSub::getByHashkey($topic, $callback);
|
||||||
if (!$sub) {
|
if (!$sub) {
|
||||||
common_log(LOG_ERR, "Skipping PuSH delivery for deleted(?) consumer $callback on $topic");
|
common_log(LOG_ERR, "Skipping WebSub delivery for deleted(?) consumer $callback on $topic");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sub->distribute($atom);
|
$sub->distribute($atom);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_ERR, "Exception during PuSH batch out: " .
|
common_log(LOG_ERR, "Exception during WebSub batch out: " .
|
||||||
$e->getMessage() .
|
$e->getMessage() .
|
||||||
" prepping $topic to $callback");
|
" prepping $topic to $callback");
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ if (!defined('STATUSNET')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare PuSH and Salmon distributions for an outgoing message.
|
* Prepare WebSub and Salmon distributions for an outgoing message.
|
||||||
*
|
*
|
||||||
* @package OStatusPlugin
|
* @package OStatusPlugin
|
||||||
* @author Brion Vibber <brion@status.net>
|
* @author Brion Vibber <brion@status.net>
|
||||||
|
@ -30,7 +30,7 @@ if (!defined('STATUSNET')) {
|
||||||
class OStatusQueueHandler extends QueueHandler
|
class OStatusQueueHandler extends QueueHandler
|
||||||
{
|
{
|
||||||
// If we have more than this many subscribing sites on a single feed,
|
// If we have more than this many subscribing sites on a single feed,
|
||||||
// break up the PuSH distribution into smaller batches which will be
|
// break up the WebSub distribution into smaller batches which will be
|
||||||
// rolled into the queue progressively. This reduces disruption to
|
// rolled into the queue progressively. This reduces disruption to
|
||||||
// other, shorter activities being enqueued while we work.
|
// other, shorter activities being enqueued while we work.
|
||||||
const MAX_UNBATCHED = 50;
|
const MAX_UNBATCHED = 50;
|
||||||
|
@ -132,7 +132,7 @@ class OStatusQueueHandler extends QueueHandler
|
||||||
{
|
{
|
||||||
if ($this->user) {
|
if ($this->user) {
|
||||||
common_debug("OSTATUS [{$this->notice->getID()}]: pushing feed for local user {$this->user->getID()}");
|
common_debug("OSTATUS [{$this->notice->getID()}]: pushing feed for local user {$this->user->getID()}");
|
||||||
// For local posts, ping the PuSH hub to update their feed.
|
// For local posts, ping the WebSub hub to update their feed.
|
||||||
// http://identi.ca/api/statuses/user_timeline/1.atom
|
// http://identi.ca/api/statuses/user_timeline/1.atom
|
||||||
$feed = common_local_url('ApiTimelineUser',
|
$feed = common_local_url('ApiTimelineUser',
|
||||||
array('id' => $this->user->id,
|
array('id' => $this->user->id,
|
||||||
|
@ -144,7 +144,7 @@ class OStatusQueueHandler extends QueueHandler
|
||||||
function pushGroup(User_group $group)
|
function pushGroup(User_group $group)
|
||||||
{
|
{
|
||||||
common_debug("OSTATUS [{$this->notice->getID()}]: pushing group '{$group->getNickname()}' profile_id={$group->profile_id}");
|
common_debug("OSTATUS [{$this->notice->getID()}]: pushing group '{$group->getNickname()}' profile_id={$group->profile_id}");
|
||||||
// For a local group, ping the PuSH hub to update its feed.
|
// For a local group, ping the WebSub hub to update its feed.
|
||||||
// Updates may come from either a local or a remote user.
|
// Updates may come from either a local or a remote user.
|
||||||
$feed = common_local_url('ApiTimelineGroup',
|
$feed = common_local_url('ApiTimelineGroup',
|
||||||
array('id' => $group->getID(),
|
array('id' => $group->getID(),
|
||||||
|
@ -155,7 +155,7 @@ class OStatusQueueHandler extends QueueHandler
|
||||||
function pushPeopletag($ptag)
|
function pushPeopletag($ptag)
|
||||||
{
|
{
|
||||||
common_debug("OSTATUS [{$this->notice->getID()}]: pushing peopletag '{$ptag->id}'");
|
common_debug("OSTATUS [{$this->notice->getID()}]: pushing peopletag '{$ptag->id}'");
|
||||||
// For a local people tag, ping the PuSH hub to update its feed.
|
// For a local people tag, ping the WebSub hub to update its feed.
|
||||||
// Updates may come from either a local or a remote user.
|
// Updates may come from either a local or a remote user.
|
||||||
$feed = common_local_url('ApiTimelineList',
|
$feed = common_local_url('ApiTimelineList',
|
||||||
array('id' => $ptag->id,
|
array('id' => $ptag->id,
|
||||||
|
@ -221,7 +221,7 @@ class OStatusQueueHandler extends QueueHandler
|
||||||
$atom = call_user_func_array($callback, $args);
|
$atom = call_user_func_array($callback, $args);
|
||||||
$this->pushFeedInternal($atom, $sub);
|
$this->pushFeedInternal($atom, $sub);
|
||||||
} else {
|
} else {
|
||||||
common_log(LOG_INFO, "OSTATUS [{$this->notice->getID()}]: No PuSH subscribers for $feed");
|
common_log(LOG_INFO, "OSTATUS [{$this->notice->getID()}]: No WebSub subscribers for $feed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ class OStatusQueueHandler extends QueueHandler
|
||||||
* Not guaranteed safe in an environment with database replication.
|
* Not guaranteed safe in an environment with database replication.
|
||||||
*
|
*
|
||||||
* @param string $feed feed topic URI
|
* @param string $feed feed topic URI
|
||||||
* @param string $hub PuSH hub URI
|
* @param string $hub WebSub hub URI
|
||||||
* @fixme can consolidate pings for user & group posts
|
* @fixme can consolidate pings for user & group posts
|
||||||
*/
|
*/
|
||||||
function pushFeedExternal($feed, $hub)
|
function pushFeedExternal($feed, $hub)
|
||||||
|
@ -242,15 +242,15 @@ class OStatusQueueHandler extends QueueHandler
|
||||||
'hub.url' => $feed);
|
'hub.url' => $feed);
|
||||||
$response = $client->post($hub, array(), $data);
|
$response = $client->post($hub, array(), $data);
|
||||||
if ($response->getStatus() == 204) {
|
if ($response->getStatus() == 204) {
|
||||||
common_log(LOG_INFO, "PuSH ping to hub $hub for $feed ok");
|
common_log(LOG_INFO, "WebSub ping to hub $hub for $feed ok");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
common_log(LOG_ERR, "PuSH ping to hub $hub for $feed failed with HTTP " .
|
common_log(LOG_ERR, "WebSub ping to hub $hub for $feed failed with HTTP " .
|
||||||
$response->getStatus() . ': ' .
|
$response->getStatus() . ': ' .
|
||||||
$response->getBody());
|
$response->getBody());
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_ERR, "PuSH ping to hub $hub for $feed failed: " . $e->getMessage());
|
common_log(LOG_ERR, "WebSub ping to hub $hub for $feed failed: " . $e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ class OStatusQueueHandler extends QueueHandler
|
||||||
*/
|
*/
|
||||||
function pushFeedInternal($atom, $sub)
|
function pushFeedInternal($atom, $sub)
|
||||||
{
|
{
|
||||||
common_log(LOG_INFO, "Preparing $sub->N PuSH distribution(s) for $sub->topic");
|
common_log(LOG_INFO, "Preparing $sub->N WebSub distribution(s) for $sub->topic");
|
||||||
$n = 0;
|
$n = 0;
|
||||||
$batch = array();
|
$batch = array();
|
||||||
while ($sub->fetch()) {
|
while ($sub->fetch()) {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a feed distribution POST from a PuSH hub.
|
* Process a feed distribution POST from a WebSub (previously PuSH) hub.
|
||||||
* @package FeedSub
|
* @package FeedSub
|
||||||
* @author Brion Vibber <brion@status.net>
|
* @author Brion Vibber <brion@status.net>
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +45,7 @@ class PushInQueueHandler extends QueueHandler
|
||||||
} catch(NoResultException $e) {
|
} catch(NoResultException $e) {
|
||||||
common_log(LOG_INFO, "Discarding POST to unknown feed subscription id {$feedsub_id}");
|
common_log(LOG_INFO, "Discarding POST to unknown feed subscription id {$feedsub_id}");
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
common_log(LOG_ERR, "Exception "._ve(get_class($e))." during PuSH input processing for {$feedsub->getUri()}: " . $e->getMessage());
|
common_log(LOG_ERR, "Exception "._ve(get_class($e))." during WebSub push input processing for {$feedsub->getUri()}: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class PushRenewQueueHandler extends QueueHandler
|
||||||
common_log(LOG_INFO, "Renewing feed subscription\n\tExp.: {$feedsub->sub_end}\n\tFeed: {$feedsub->uri}\n\tHub: {$feedsub->huburi}");
|
common_log(LOG_INFO, "Renewing feed subscription\n\tExp.: {$feedsub->sub_end}\n\tFeed: {$feedsub->uri}\n\tHub: {$feedsub->huburi}");
|
||||||
$feedsub->renew();
|
$feedsub->renew();
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
common_log(LOG_ERR, "Exception during PuSH renew processing for $feedsub->uri: " . $e->getMessage());
|
common_log(LOG_ERR, "Exception during WebSub renew processing for $feedsub->uri: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
common_log(LOG_ERR, "Discarding renew for unknown feed subscription id $feedsub_id");
|
common_log(LOG_ERR, "Discarding renew for unknown feed subscription id $feedsub_id");
|
||||||
|
|
|
@ -25,7 +25,7 @@ $shortoptions = 'u';
|
||||||
|
|
||||||
$helptext = <<<END_OF_HELP
|
$helptext = <<<END_OF_HELP
|
||||||
resub-feed.php [options] http://example.com/atom-feed-url
|
resub-feed.php [options] http://example.com/atom-feed-url
|
||||||
Reinitialize the PuSH subscription for the given feed. This may help get
|
Reinitialize the WebSub subscription for the given feed. This may help get
|
||||||
things restarted if we and the hub have gotten our states out of sync.
|
things restarted if we and the hub have gotten our states out of sync.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
|
@ -24,7 +24,7 @@ $longoptions = array('skip=', 'count=');
|
||||||
|
|
||||||
$helptext = <<<END_OF_HELP
|
$helptext = <<<END_OF_HELP
|
||||||
testfeed.php [options] http://example.com/atom-feed-url
|
testfeed.php [options] http://example.com/atom-feed-url
|
||||||
Pull an Atom feed and run items in it as though they were live PuSH updates.
|
Pull an Atom feed and run items in it as though they were live WebSub updates.
|
||||||
Mainly intended for testing funky feed formats.
|
Mainly intended for testing funky feed formats.
|
||||||
|
|
||||||
--skip=N Ignore the first N items in the feed.
|
--skip=N Ignore the first N items in the feed.
|
||||||
|
|
|
@ -24,7 +24,7 @@ $helptext = <<<END_OF_HELP
|
||||||
update-profile.php [options] http://example.com/profile/url
|
update-profile.php [options] http://example.com/profile/url
|
||||||
|
|
||||||
Rerun profile and feed info discovery for the given OStatus remote profile,
|
Rerun profile and feed info discovery for the given OStatus remote profile,
|
||||||
and reinitialize its PuSH subscription for the given feed. This may help get
|
and reinitialize its WebSub subscription for the given feed. This may help get
|
||||||
things restarted if the hub or feed URLs have changed for the profile.
|
things restarted if the hub or feed URLs have changed for the profile.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ class OStatusTester extends TestBase
|
||||||
$this->assertTrue($this->pub->hasSubscriber($this->sub->getProfileUri()));
|
$this->assertTrue($this->pub->hasSubscriber($this->sub->getProfileUri()));
|
||||||
|
|
||||||
$name = $this->sub->username;
|
$name = $this->sub->username;
|
||||||
$post = $this->pub->post("Regular post, which $name should get via PuSH");
|
$post = $this->pub->post("Regular post, which $name should get via WebSub");
|
||||||
$this->sub->assertReceived($post);
|
$this->sub->assertReceived($post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
The SubMirror plugin pull PuSH-enabled feeds into your timeline.
|
The SubMirror plugin pull WebSub-enabled feeds into your timeline.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
Loading…
Reference in New Issue