From f8b07e1935dd6d035b7458141eca099a2445b077 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 17 Nov 2013 20:43:50 -0800 Subject: filter out duplicate recipients on local deliveries. We only need to deliver stuff once to any particular channel. --- include/zot.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'include/zot.php') diff --git a/include/zot.php b/include/zot.php index 018f00ba5..1191cc221 100644 --- a/include/zot.php +++ b/include/zot.php @@ -910,11 +910,29 @@ function zot_import($arr, $sender_url) { $deliveries = allowed_public_recips($i); } + + // Go through the hash array and remove duplicates. array_unique() won't do this because the array is more than one level. + + $no_dups = array(); + if($deliveries) { + foreach($deliveries as $d) { + if(! in_array($d['hash'],$no_dups)) + $no_dups[] = $d['hash']; + } + + if($no_dups) { + $deliveries = array(); + foreach($no_dups as $n) { + $deliveries[] = array('hash' => $n); + } + } + } + if(! $deliveries) { logger('zot_import: no deliveries on this site'); continue; } - + if($i['message']) { if($i['message']['type'] === 'activity') { $arr = get_item_elements($i['message']); -- cgit v1.2.3