PuSH 0.4: No outgoing 'sync' verifications. Feed renewal script. No auto-renewal.

Among other things (such as permanent subscriptions), Pubsubhubbub 0.4
removed the "sync" verification method. This means that any incoming
PuSH subscription requests that follow the 0.4 spec won't really
_require_that we handle it as a background process, but if we were to
try direct verification of the subscription - and fail - there's no way
we could  pick up the ball again. So _essentially_ we require background
processing with retries.

This means we must implement something like the "poorman cron" or
similar, so background processing can be handled
on-demand/on-site-visit. This is how Friendica, Drupal etc. handles it
and is necessary for environments where we can't run separate queue
daemons.

When the poorman-cron-ish thing is implemented, auto-renewal will work
for all users.

PuSH 0.4 spec:
    https://pubsubhubbub.googlecode.com/git/pubsubhubbub-core-0.4.html
More on PuSH 0.4 release (incl. breaking changes):
    https://groups.google.com/forum/#!msg/pubsubhubbub/7RPlYMds4RI/2mIHQTdV3aoJ
This commit is contained in:
Mikael Nordfeldth
2013-11-02 20:02:28 +01:00
parent 2cecfe8f82
commit ab4113168f
5 changed files with 86 additions and 50 deletions

View File

@@ -89,20 +89,12 @@ class PushHubAction extends Action
throw new ClientException(sprintf(_m('Unsupported hub.topic %s this hub only serves local user and group Atom feeds.'),$topic));
}
$verify = $this->arg('hub.verify'); // @fixme may be multiple
if ($verify != 'sync' && $verify != 'async') {
// TRANS: Client exception. %s is sync or async.
throw new ClientException(sprintf(_m('Invalid hub.verify "%s". It must be sync or async.'),$verify));
}
$lease = $this->arg('hub.lease_seconds', null);
if ($mode == 'subscribe' && $lease != '' && !preg_match('/^\d+$/', $lease)) {
// 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));
}
$token = $this->arg('hub.verify_token', null);
$secret = $this->arg('hub.secret', null);
if ($secret != '' && strlen($secret) >= 200) {
// TRANS: Client exception. %s is the invalid hub secret.
@@ -110,7 +102,7 @@ class PushHubAction extends Action
}
$sub = HubSub::getByHashkey($topic, $callback);
if (!$sub) {
if (!$sub instanceof HubSub) {
// Creating a new one!
$sub = new HubSub();
$sub->topic = $topic;
@@ -125,16 +117,14 @@ class PushHubAction extends Action
}
}
if (!common_config('queue', 'enabled')) {
// Won't be able to background it.
$verify = 'sync';
}
if ($verify == 'async') {
$sub->scheduleVerify($mode, $token);
header('HTTP/1.1 202 Accepted');
} else {
$verify = $this->arg('hub.verify'); // TODO: deprecated
$token = $this->arg('hub.verify_token', null); // TODO: deprecated
if ($verify == 'sync') { // pre-0.4 PuSH
$sub->verify($mode, $token);
header('HTTP/1.1 204 No Content');
} else { // If $verify is not "sync", we might be using PuSH 0.4
$sub->scheduleVerify($mode, $token); // If we were certain it's PuSH 0.4, token could be removed
header('HTTP/1.1 202 Accepted');
}
}