From 22b3ddab66f128ca05a42ebfccda0964bddd7509 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Nov 2018 19:24:02 -0800 Subject: refresh packets --- Zotlabs/Daemon/Notifier.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Daemon/Notifier.php') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index f74c8f11c..48928f5ba 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -2,6 +2,8 @@ namespace Zotlabs\Daemon; +use Zotlabs\Lib\Libzot; + require_once('include/queue_fn.php'); require_once('include/html2plain.php'); require_once('include/conversation.php'); @@ -561,7 +563,7 @@ class Notifier { logger('notifier_hub: ' . $hub['hubloc_url'],LOGGER_DEBUG); - if($hub['hubloc_network'] !== 'zot') { + if(! in_array($hub['hubloc_network'], [ 'zot','zot6' ])) { $narr = [ 'channel' => $channel, 'upstream' => $upstream, @@ -610,14 +612,21 @@ class Notifier { continue; } - // default: zot protocol + if(! in_array($hub['hubloc_network'], [ 'zot','zot6' ])) { + continue; + } $hash = random_string(); $packet = null; $pmsg = ''; if($packet_type === 'refresh' || $packet_type === 'purge') { - $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); + if($hub['hubloc_network'] === 'zot6') { + $packet = Libzot::build_packet($channel, $packet_type, ids_to_array($packet_recips,'hash')); + } + else { + $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); + } } if($packet_type === 'keychange') { $pmsg = get_pconfig($channel['channel_id'],'system','keychange'); -- cgit v1.2.3 From c80ac58effdb71fe457daa164053ea57c1513e68 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Nov 2018 20:42:09 -0800 Subject: add zot6 delivery method --- Zotlabs/Daemon/Notifier.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Daemon/Notifier.php') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 48928f5ba..9a4b14d57 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -672,6 +672,7 @@ class Notifier { 'account_id' => $target_item['aid'], 'channel_id' => $target_item['uid'], 'posturl' => $hub['hubloc_callback'], + 'driver' => $hub['hubloc_network'], 'notify' => $packet, 'msg' => json_encode($encoded_item) ] -- cgit v1.2.3 From da452decf695ceac249642ec9d12fb724fa547f7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 11 Nov 2018 15:12:01 -0800 Subject: more z6 debugging --- Zotlabs/Daemon/Notifier.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Daemon/Notifier.php') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 9a4b14d57..c7360b83c 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -645,6 +645,7 @@ class Notifier { 'account_id' => $channel['channel_account_id'], 'channel_id' => $channel['channel_id'], 'posturl' => $hub['hubloc_callback'], + 'driver' => $hub['hubloc_network'], 'notify' => $packet, 'msg' => (($pmsg) ? json_encode($pmsg) : '') )); -- cgit v1.2.3 From 171ff54ea407595a85e971f62abc556faf3dec73 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 11 Nov 2018 21:55:10 -0800 Subject: translate zot message packets to zot6 for delivery --- Zotlabs/Daemon/Notifier.php | 47 +++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'Zotlabs/Daemon/Notifier.php') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index c7360b83c..8b81c49da 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -346,7 +346,16 @@ class Notifier { return; $encoded_item = encode_item($target_item); - + + // activitystreams version + $m = get_iconfig($target_item,'activitystreams','signed_data'); + if($m) { + $activity = json_decode($m,true); + } + else { + $activity = \Zotlabs\Lib\Activity::encode_activity($target_item); + } + // Send comments to the owner to re-deliver to everybody in the conversation // We only do this if the item in question originated on this site. This prevents looping. // To clarify, a site accepting a new comment is responsible for sending it to the owner for relay. @@ -616,7 +625,7 @@ class Notifier { continue; } - $hash = random_string(); + $hash = new_uuid(); $packet = null; $pmsg = ''; @@ -628,11 +637,11 @@ class Notifier { $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } } - if($packet_type === 'keychange') { + if($packet_type === 'keychange' && $hub['hubloc_network'] === 'zot') { $pmsg = get_pconfig($channel['channel_id'],'system','keychange'); $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } - elseif($packet_type === 'request') { + elseif($packet_type === 'request' && $hub['hubloc_network'] === 'zot') { $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) @@ -653,18 +662,32 @@ class Notifier { else { $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : ''); - // currently zot6 delivery is only performed on normal items and not sync items or mail or anything else - // Eventually we will do this for all deliveries, but for now ensure this is precisely what we are dealing - // with before switching to zot6 as the primary zot6 handler checks for the existence of a message delivery report - // to trigger dequeue'ing - $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (! array_key_exists('allow_cid',$encoded_item))) ? true : false); - if($z6) { - $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + if($hub['hubloc_network'] === 'zot6') { + $zenv = []; + if($env) { + foreach($env as $e) { + $zenv[] = $e['hash']; + } + } + + $packet_type = (($upstream || $uplink) ? 'response' : 'activity'); + $packet = Libzot::build_packet($channel,$packet_type,$zenv,$activity,'activitystreams',(($private) ? $hub['hubloc_sitekey'] : null),$hub['site_crypto']); } else { - $packet = zot_build_packet($channel,'notify',$env, (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + // currently zot6 delivery is only performed on normal items and not sync items or mail or anything else + // Eventually we will do this for all deliveries, but for now ensure this is precisely what we are dealing + // with before switching to zot6 as the primary zot6 handler checks for the existence of a message delivery report + // to trigger dequeue'ing + + $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (! array_key_exists('allow_cid',$encoded_item))) ? true : false); + if($z6) { + $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + } + else { + $packet = zot_build_packet($channel,'notify',$env, (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + } } queue_insert( -- cgit v1.2.3