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 --- include/queue_fn.php | 99 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 23 deletions(-) (limited to 'include/queue_fn.php') diff --git a/include/queue_fn.php b/include/queue_fn.php index f05bac5b0..074e3c407 100644 --- a/include/queue_fn.php +++ b/include/queue_fn.php @@ -1,5 +1,9 @@ run(true); + logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA); + logger('deliver: local zot 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 zot delivery succeeded to ' . $outq['outq_posturl']); + Libzot::process_response($outq['outq_posturl'],$result, $outq); + } + else { + logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']); + logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); + update_queue_item($outq['outq_hash'],10); + } - if($outq['outq_msg'] && $outq['outq_channel']) { - $channel = channelx_by_n($outq['outq_channel']); + } + return; } + else { - $host_crypto = null; + $channel = 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' order by hubloc_id desc limit 1", - dbesc($base) - ); - if($h) { - $host_crypto = $h[0]; + if($outq['outq_msg'] && $outq['outq_channel']) { + $channel = channelx_by_n($outq['outq_channel']); } - } - $msg = $outq['outq_notify']; + $host_crypto = null; - $result = zot_zot($outq['outq_posturl'],$msg,$channel,$host_crypto); + if($channel && $base) { + $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' order by hubloc_id desc limit 1", + dbesc($base) + ); + if($h) { + $host_crypto = $h[0]; + } + } + $msg = $outq['outq_notify']; - if($result['success']) { - logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']); - zot_process_response($outq['outq_posturl'],$result, $outq); - } - else { - logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']); - logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); - update_queue_item($outq['outq_hash'],10); + $result = zot_zot($outq['outq_posturl'],$msg,$channel,$host_crypto); + + + if($result['success']) { + logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']); + zot_process_response($outq['outq_posturl'],$result, $outq); + } + else { + logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']); + logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); + update_queue_item($outq['outq_hash'],10); + } + return; } - return; -} +} \ No newline at end of file -- 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 --- include/queue_fn.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'include/queue_fn.php') diff --git a/include/queue_fn.php b/include/queue_fn.php index 074e3c407..f7e2922c6 100644 --- a/include/queue_fn.php +++ b/include/queue_fn.php @@ -237,7 +237,7 @@ function queue_deliver($outq, $immediate = false) { $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 zot delivery succeeded to ' . $outq['outq_posturl']); + logger('deliver: local zot6 delivery succeeded to ' . $outq['outq_posturl']); Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq); } else { @@ -250,8 +250,7 @@ function queue_deliver($outq, $immediate = false) { $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", + $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) { @@ -264,12 +263,12 @@ function queue_deliver($outq, $immediate = false) { $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto); if($result['success']) { - logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']); + logger('deliver: remote zot6 delivery succeeded to ' . $outq['outq_posturl']); Libzot::process_response($outq['outq_posturl'],$result, $outq); } else { - logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']); - logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); + 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); } -- cgit v1.2.3