From b739f91caa1522522a4ce093d7c63f0f4c777085 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 29 Mar 2020 15:18:49 +0000 Subject: use Libsync::build_sync_packet() in mod item, default Lib/Queue driver to zot6 and some whitespace cleanup in queue_deliver() --- Zotlabs/Lib/Libsync.php | 1 + Zotlabs/Lib/Queue.php | 2 +- Zotlabs/Module/Item.php | 7 +++-- include/queue_fn.php | 80 ++++++++++++++++++++++++------------------------- 4 files changed, 46 insertions(+), 44 deletions(-) diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index de389c0a9..b7cda1770 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -150,6 +150,7 @@ class Libsync { 'account_id' => $channel['channel_account_id'], 'channel_id' => $channel['channel_id'], 'posturl' => $hub['hubloc_callback'], + 'driver' => $hub['hubloc_network'], 'notify' => $n, 'msg' => EMPTY_STR )); diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php index 49891a55b..6acc58bc5 100644 --- a/Zotlabs/Lib/Queue.php +++ b/Zotlabs/Lib/Queue.php @@ -116,7 +116,7 @@ class Queue { dbesc($arr['hash']), intval($arr['account_id']), intval($arr['channel_id']), - dbesc(($arr['driver']) ? $arr['driver'] : 'zot'), + dbesc(($arr['driver']) ? $arr['driver'] : 'zot6'), dbesc($arr['posturl']), intval(1), intval(($arr['priority']) ? $arr['priority'] : 0), diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 86b5c1c7a..fcc040e01 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -11,6 +11,7 @@ use Zotlabs\Lib\ActivityStreams; use Zotlabs\Lib\LDSignatures; use Zotlabs\Web\HTTPSig; use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\Libsync; use Zotlabs\Lib\ThreadListener; use App; @@ -1155,7 +1156,7 @@ class Item extends Controller { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true)))); } } if(! $nopush) @@ -1258,7 +1259,7 @@ class Item extends Controller { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true)))); } } @@ -1360,7 +1361,7 @@ class Item extends Controller { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true)))); } if($complex) { diff --git a/include/queue_fn.php b/include/queue_fn.php index 865228041..b72730d2f 100644 --- a/include/queue_fn.php +++ b/include/queue_fn.php @@ -228,49 +228,49 @@ function queue_deliver($outq, $immediate = false) { // normal zot delivery - logger('deliver: dest: ' . $outq['outq_posturl'], LOGGER_DEBUG); + logger('deliver: dest: ' . $outq['outq_posturl'] . ' driver: ' . $outq['outq_driver'], LOGGER_DEBUG); if($outq['outq_driver'] === 'zot6') { - if($outq['outq_posturl'] === z_root() . '/zot') { - // local delivery - $zot = new Receiver(new Zot6Handler(),$outq['outq_notify']); - $result = $zot->run(true); - logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA); - logger('deliver: local zot6 delivery succeeded to ' . $outq['outq_posturl']); - Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq); - } - else { - logger('remote'); - $channel = null; - - if($outq['outq_channel']) { - $channel = channelx_by_n($outq['outq_channel']); - } - - $host_crypto = null; - if($channel && $base) { - $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1", - dbesc($base) - ); - if($h) { - $host_crypto = $h[0]; - } - } - - $msg = $outq['outq_notify']; - - $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto); - - if($result['success']) { - logger('deliver: remote zot6 delivery succeeded to ' . $outq['outq_posturl']); - Libzot::process_response($outq['outq_posturl'],$result, $outq); - } - else { - logger('deliver: remote zot6 delivery failed to ' . $outq['outq_posturl']); - logger('deliver: remote zot6 delivery fail data: ' . print_r($result,true), LOGGER_DATA); - update_queue_item($outq['outq_hash'],10); - } + if($outq['outq_posturl'] === z_root() . '/zot') { + // local delivery + $zot = new Receiver(new Zot6Handler(),$outq['outq_notify']); + $result = $zot->run(true); + logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA); + logger('deliver: local zot6 delivery succeeded to ' . $outq['outq_posturl']); + Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq); + } + else { + logger('remote'); + $channel = null; + + if($outq['outq_channel']) { + $channel = channelx_by_n($outq['outq_channel']); + } + + $host_crypto = null; + if($channel && $base) { + $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1", + dbesc($base) + ); + if($h) { + $host_crypto = $h[0]; + } + } + + $msg = $outq['outq_notify']; + + $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto); + + if($result['success']) { + logger('deliver: remote zot6 delivery succeeded to ' . $outq['outq_posturl']); + Libzot::process_response($outq['outq_posturl'],$result, $outq); + } + else { + logger('deliver: remote zot6 delivery failed to ' . $outq['outq_posturl']); + logger('deliver: remote zot6 delivery fail data: ' . print_r($result,true), LOGGER_DATA); + update_queue_item($outq['outq_hash'],10); + } } return; -- cgit v1.2.3