diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-10-15 04:20:42 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-10-15 04:20:42 -0700 |
commit | 35a9b49ed06c58b53f81cf5ef476191807157925 (patch) | |
tree | 506f0008b23ee46b30b719084dbc0bf42b3b84cf /include/notifier.php | |
parent | e9aa6eb0c7c9c027cbd13138ae5247bbd007e180 (diff) | |
download | volse-hubzilla-35a9b49ed06c58b53f81cf5ef476191807157925.tar.gz volse-hubzilla-35a9b49ed06c58b53f81cf5ef476191807157925.tar.bz2 volse-hubzilla-35a9b49ed06c58b53f81cf5ef476191807157925.zip |
allow for multiple pubsub hubs so everything can still work when/if one goes flaky
(Google's hub has been particularly unreliable recently and the symptoms are that
you just stop receiving updates, and/or updates you send are silently dropped and
never delivered). Also add more instrumentation to help debug pubsub issues.
Diffstat (limited to 'include/notifier.php')
-rw-r--r-- | include/notifier.php | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/include/notifier.php b/include/notifier.php index 9866c0232..bef46677c 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -149,8 +149,18 @@ $atom = ''; - $hubxml = ((strlen($hub)) ? '<link rel="hub" href="' . xmlify($hub) . '" />' . "\n" : ''); - + $hubxml = ''; + if(strlen($hub)) { + $hubs = explode(',', $hub); + if(count($hubs)) { + foreach($hubs as $h) { + $h = trim($h); + if(! strlen($h)) + continue; + $hubxml .= '<link rel="hub" href="' . xmlify($h) . '" />' . "\n" ; + } + } + } $atom .= replace_macros($feed_template, array( '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname'] ), @@ -314,10 +324,21 @@ } if((strlen($hub)) && ($notify_hub)) { - $params = 'hub.mode=publish&hub.url=' . urlencode($a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] ); - post_url($hub,$params); - if($debugging) { - file_put_contents('pubsub.out', "\n\n" . "Pinged hub at " . datetime_convert() . "\n" . "Hub returned " . $a->get_curl_code() . "\n\n" , FILE_APPEND); + $hubs = explode(',', $hub); + if(count($hubs)) { + foreach($hubs as $h) { + $h = trim($h); + if(! strlen($h)) + continue; + $params = 'hub.mode=publish&hub.url=' . urlencode($a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] ); + post_url($h,$params); + if($debugging) { + file_put_contents('pubsub.out', "\n\n" . "Pinged hub " . $h . ' at ' + . datetime_convert() . "\n" . "Hub returned " . $a->get_curl_code() . "\n\n" , FILE_APPEND); + } + if(count($hubs) > 1) + sleep(7); // try and avoid multiple hubs responding at precisely the same time + } } } |