aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-04-18 17:26:50 -0700
committerzotlabs <mike@macgirvin.com>2017-04-18 17:26:50 -0700
commit368f88740a3bc6fca610ad0a0d6e68f86e7ef968 (patch)
tree928d544de6d1209fec2bce6b6144cd7801b9fd6f /Zotlabs
parentab369ab91dde04807c7b71df1654c9847c8f4c3d (diff)
downloadvolse-hubzilla-368f88740a3bc6fca610ad0a0d6e68f86e7ef968.tar.gz
volse-hubzilla-368f88740a3bc6fca610ad0a0d6e68f86e7ef968.tar.bz2
volse-hubzilla-368f88740a3bc6fca610ad0a0d6e68f86e7ef968.zip
envelope privacy
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Notifier.php60
1 files changed, 29 insertions, 31 deletions
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php
index 63ced4f56..48f1d2757 100644
--- a/Zotlabs/Daemon/Notifier.php
+++ b/Zotlabs/Daemon/Notifier.php
@@ -5,6 +5,11 @@ namespace Zotlabs\Daemon;
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
require_once('include/conversation.php');
+require_once('include/zot.php');
+require_once('include/items.php');
+require_once('include/bbcode.php');
+
+
/*
* This file was at one time responsible for doing all deliveries, but this caused
@@ -68,13 +73,6 @@ require_once('include/conversation.php');
*/
-require_once('include/zot.php');
-require_once('include/queue_fn.php');
-require_once('include/datetime.php');
-require_once('include/items.php');
-require_once('include/bbcode.php');
-require_once('include/channel.php');
-
class Notifier {
@@ -98,16 +96,6 @@ class Notifier {
$deliveries = array();
- $dead_hubs = array();
-
- $dh = q("select site_url from site where site_dead = 1");
- if($dh) {
- foreach($dh as $dead) {
- $dead_hubs[] = $dead['site_url'];
- }
- }
-
-
$request = false;
$mail = false;
$top_level = false;
@@ -489,10 +477,10 @@ class Notifier {
// Now we have collected recipients (except for external mentions, FIXME)
- // Let's reduce this to a set of hubs.
+ // Let's reduce this to a set of hubs; checking that the site is not dead.
$r = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ")
- and hubloc_error = 0 and hubloc_deleted = 0"
+ and hubloc_error = 0 and hubloc_deleted = 0 and site_dead = 0"
);
@@ -506,23 +494,31 @@ class Notifier {
/**
- * 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.
+ * 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
-
+ $hublist = []; // this provides an easily printable list for the logs
+ $dhubs = []; // delivery hubs where we store our resulting unique array
+ $keys = []; // array of keys to check uniquness for zot hubs
+ $urls = []; // array of urls to check uniqueness of hubs from other networks
+ $hub_env = []; // per-hub envelope so we don't broadcast the entire envelope to all
foreach($hubs as $hub) {
- if(in_array($hub['hubloc_url'],$dead_hubs)) {
- logger('skipping dead hub: ' . $hub['hubloc_url'], LOGGER_DEBUG, LOG_INFO);
- continue;
+
+ if($env_recips) {
+ foreach($env_recips as $er) {
+ if($hub['hubloc_hash'] === $er['hash']) {
+ if(! array_key_exists($hub['hubloc_host'] . $hub['hubloc_sitekey'], $hub_env)) {
+ $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] = [];
+ }
+ $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']][] = $er;
+ }
+ }
}
+
if($hub['hubloc_network'] == 'zot') {
if(! in_array($hub['hubloc_sitekey'],$keys)) {
@@ -603,7 +599,8 @@ class Notifier {
$packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null));
}
elseif($packet_type === 'request') {
- $packet = zot_build_packet($channel,$packet_type,$env_recips,$hub['hubloc_sitekey'],$hub['site_crypto'],
+ $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : '');
+ $packet = zot_build_packet($channel,$packet_type,$env,$hub['hubloc_sitekey'],$hub['site_crypto'],
$hash, array('message_id' => $request_message_id)
);
}
@@ -618,7 +615,8 @@ class Notifier {
));
}
else {
- $packet = zot_build_packet($channel,'notify',$env_recips,(($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash);
+ $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : '');
+ $packet = zot_build_packet($channel,'notify',$env,(($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash);
queue_insert(array(
'hash' => $hash,
'account_id' => $target_item['aid'],