aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-11-08 20:42:09 -0800
committerzotlabs <mike@macgirvin.com>2018-11-08 20:42:09 -0800
commitc80ac58effdb71fe457daa164053ea57c1513e68 (patch)
tree3462b7be69f2f72b71997373473b6e6a8a48faaa
parentd56e1f6285fd2e4cc7b2f9cd88df88a26c5d2ad7 (diff)
downloadvolse-hubzilla-c80ac58effdb71fe457daa164053ea57c1513e68.tar.gz
volse-hubzilla-c80ac58effdb71fe457daa164053ea57c1513e68.tar.bz2
volse-hubzilla-c80ac58effdb71fe457daa164053ea57c1513e68.zip
add zot6 delivery method
-rw-r--r--Zotlabs/Daemon/Notifier.php1
-rw-r--r--include/queue_fn.php99
2 files changed, 77 insertions, 23 deletions
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)
]
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 @@
<?php /** @file */
+use Zotlabs\Lib\Libzot;
+use Zotlabs\Zot6\Receiver;
+use Zotlabs\Zot6\Zot6Handler;
+
function update_queue_item($id, $add_priority = 0) {
logger('queue: requeue item ' . $id,LOGGER_DEBUG);
$x = q("select outq_created, outq_posturl from outq where outq_hash = '%s' limit 1",
@@ -226,37 +230,86 @@ function queue_deliver($outq, $immediate = false) {
logger('deliver: dest: ' . $outq['outq_posturl'], LOGGER_DEBUG);
- $channel = null;
+ 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 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