From b9dc23844c6363a876479a6f867f4d3eb9190928 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 17 Dec 2014 11:57:16 -0800 Subject: make unique hub filter more robust and straight-forward so it's easier to understand and debug since it's such a critical piece of the delivery chain --- include/notifier.php | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index 931732686..e1eb0c554 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -510,16 +510,34 @@ function notifier_run($argv, $argc){ $hubs = $r; - $hublist = array(); - $dhubs = array(); - $keys = array(); + + /** + * Reduce the hubs to those that are unique. For zot hubs, we need to verify uniqueness by the sitekey, since it may have been + * a re-install which has not yet been detected and pruned. + * For other networks which don't have or require sitekeys, we'll have to use the URL + */ + + + $hublist = array(); // this provides an easily printable list for the logs + $dhubs = array(); // delivery hubs where we store our resulting unique array + $keys = array(); // array of keys to check uniquness for zot hubs + $urls = array(); // array of urls to check uniqueness of hubs from other networks + foreach($hubs as $hub) { - if((! $hub['hubloc_sitekey']) || (! in_array($hub['hubloc_sitekey'],$keys))) { - $hublist[] = $hub['hubloc_host']; - $dhubs[] = $hub; - if($hub['hubloc_sitekey']) + if($hub['hubloc_network'] == 'zot') { + if(! in_array($hub['hubloc_sitekey'],$keys)) { + $hublist[] = $hub['hubloc_host']; + $dhubs[] = $hub; $keys[] = $hub['hubloc_sitekey']; + } + } + else { + if(! in_array($hub['hubloc_url'],$urls)) { + $hublist[] = $hub['hubloc_host']; + $dhubs[] = $hub; + $urls[] = $hub['hubloc_url']; + } } } -- cgit v1.2.3