From db77309bc399669c5c98f4fac99f2d5f96cfbaeb Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 18 Nov 2012 19:19:16 -0800 Subject: For private messages, use hush-hush ultra top-secret mode by default --- include/items.php | 4 +++- include/notifier.php | 14 +++++++------- include/zot.php | 5 ++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/items.php b/include/items.php index 84c74fd83..5a8ecb540 100755 --- a/include/items.php +++ b/include/items.php @@ -7,7 +7,7 @@ require_once('include/Photo.php'); -function collect_recipients($item) { +function collect_recipients($item,&$private) { if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) { $allow_people = expand_acl($item['allow_cid']); @@ -18,6 +18,7 @@ function collect_recipients($item) { $recipients = array_unique(array_merge($allow_people,$allow_groups)); $deny = array_unique(array_merge($deny_people,$deny_groups)); $recipients = array_diff($recipients,$deny); + $private = true; } else { $recipients = array(); @@ -31,6 +32,7 @@ function collect_recipients($item) { $recipients[] = $rr['abook_xchan']; } } + $private = false; } return $recipients; } diff --git a/include/notifier.php b/include/notifier.php index cff504d09..f620af10a 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -209,17 +209,18 @@ function notifier_run($argv, $argc){ if($relay_to_owner) { logger('notifier: followup relay', LOGGER_DEBUG); $recipients = array($parent_item['owner_xchan']); + $private = true; if(! $encoded_item['flags']) $encoded_item['flags'] = array(); $encoded_item['flags'][] = 'relay'; } else { logger('notifier: normal distribution', LOGGER_DEBUG); - $recipients = collect_recipients($parent_item); + $private = false; + $recipients = collect_recipients($parent_item,$private); // FIXME add any additional recipients such as mentions, etc. - // don't send deletions onward for other people's stuff // TODO verify this is needed - copied logic from same place in old code @@ -227,8 +228,6 @@ function notifier_run($argv, $argc){ logger('notifier: ignoring delete notification for non-wall item'); return; } - - } logger('notifier: encoded item: ' . print_r($encoded_item,true)); @@ -238,6 +237,9 @@ function notifier_run($argv, $argc){ return; logger('notifier: recipients: ' . print_r($recipients,true)); + // Now we have collected recipients (except for external mentions, FIXME) + // Let's reduce this to a set of hubs. + $r = q("select distinct(hubloc_callback),hubloc_host,hubloc_sitekey from hubloc where hubloc_hash in (" . implode(',',$recipients) . ") group by hubloc_callback"); if(! $r) { @@ -245,8 +247,6 @@ function notifier_run($argv, $argc){ return; } $hubs = $r; - if(! $hubs) - return; $interval = ((get_config('system','delivery_interval') !== false) ? intval(get_config('system','delivery_interval')) : 2 ); @@ -260,8 +260,8 @@ function notifier_run($argv, $argc){ $current_count = 0; foreach($hubs as $hub) { - $n = zot_build_packet($channel,'notify',null,null); $hash = random_string(); + $n = zot_build_packet($channel,'notify',null,(($private) ? $hub['hubloc_sitekey'],$hash); q("insert into outq ( outq_hash, outq_account, outq_channel, outq_posturl, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' )", dbesc($hash), intval($target_item['aid']), diff --git a/include/zot.php b/include/zot.php index b313e99a9..c332579c1 100644 --- a/include/zot.php +++ b/include/zot.php @@ -85,7 +85,7 @@ function zot_notify($channel,$url,$type = 'notify',$recipients = null, $remote_k * */ -function zot_build_packet($channel,$type = 'notify',$recipients = null, $remote_key = null) { +function zot_build_packet($channel,$type = 'notify',$recipients = null, $remote_key = null, $secret = null) { $data = array( 'type' => $type, @@ -103,6 +103,9 @@ function zot_build_packet($channel,$type = 'notify',$recipients = null, $remote_ if($recipients) $data['recipients'] = $recipients; + if($secret) + $data['secret'] = $secret; + // Hush-hush ultra top-secret mode if($remote_key) { -- cgit v1.2.3