From 5b2474238eb0d257db14b0668ef25eab92e53fea Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 19 May 2016 19:42:45 -0700 Subject: first phase of daemon refactoring --- Zotlabs/Daemon/Ratenotif.php | 114 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Zotlabs/Daemon/Ratenotif.php (limited to 'Zotlabs/Daemon/Ratenotif.php') diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php new file mode 100644 index 000000000..fd2200dc9 --- /dev/null +++ b/Zotlabs/Daemon/Ratenotif.php @@ -0,0 +1,114 @@ + 'rating', + 'encoding' => 'zot', + 'target' => $r[0]['xlink_link'], + 'rating' => intval($r[0]['xlink_rating']), + 'rating_text' => $r[0]['xlink_rating_text'], + 'signature' => $r[0]['xlink_sig'], + 'edited' => $r[0]['xlink_updated'] + ); + } + + $channel = channelx_by_hash($r[0]['xlink_xchan']); + if(! $channel) { + logger('no channel'); + return; + } + + + $primary = get_directory_primary(); + + if(! $primary) + return; + + + $interval = ((get_config('system','delivery_interval') !== false) + ? intval(get_config('system','delivery_interval')) : 2 ); + + $deliveries_per_process = intval(get_config('system','delivery_batch_count')); + + if($deliveries_per_process <= 0) + $deliveries_per_process = 1; + + $deliver = array(); + + $x = z_fetch_url($primary . '/regdir'); + if($x['success']) { + $j = json_decode($x['body'],true); + if($j && $j['success'] && is_array($j['directories'])) { + + foreach($j['directories'] as $h) { + if($h == z_root()) + continue; + + $hash = random_string(); + $n = zot_build_packet($channel,'notify',null,null,$hash); + + queue_insert(array( + 'hash' => $hash, + 'account_id' => $channel['channel_account_id'], + 'channel_id' => $channel['channel_id'], + 'posturl' => $h . '/post', + 'notify' => $n, + 'msg' => json_encode($encoded_item) + )); + + $deliver[] = $hash; + + if(count($deliver) >= $deliveries_per_process) { + proc_run('php','include/deliver.php',$deliver); + $deliver = array(); + if($interval) + @time_sleep_until(microtime(true) + (float) $interval); + } + } + + // catch any stragglers + + if(count($deliver)) { + proc_run('php','include/deliver.php',$deliver); + } + } + } + + logger('ratenotif: complete.'); + return; + + } +} -- cgit v1.2.3 From 9cb1ac3de5d0f540bc6e1f5b1f4277b5a5bb9e67 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 19 May 2016 20:36:32 -0700 Subject: daemon master: create some compatibility code --- Zotlabs/Daemon/Ratenotif.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Daemon/Ratenotif.php') diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php index fd2200dc9..a404273e2 100644 --- a/Zotlabs/Daemon/Ratenotif.php +++ b/Zotlabs/Daemon/Ratenotif.php @@ -92,7 +92,7 @@ class Ratenotif { $deliver[] = $hash; if(count($deliver) >= $deliveries_per_process) { - proc_run('php','include/deliver.php',$deliver); + Master::Summon(array('Deliver',$deliver)); $deliver = array(); if($interval) @time_sleep_until(microtime(true) + (float) $interval); @@ -102,7 +102,7 @@ class Ratenotif { // catch any stragglers if(count($deliver)) { - proc_run('php','include/deliver.php',$deliver); + Master::Summon(array('Deliver',$deliver)); } } } -- cgit v1.2.3 From de006771c7fe92a889d759c2c75c1473c420ad47 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 22 May 2016 16:54:30 -0700 Subject: renamed include files identity.php (channel.php) and Contact.php (connections.php) --- Zotlabs/Daemon/Ratenotif.php | 1 - 1 file changed, 1 deletion(-) (limited to 'Zotlabs/Daemon/Ratenotif.php') diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php index a404273e2..1cba5e26d 100644 --- a/Zotlabs/Daemon/Ratenotif.php +++ b/Zotlabs/Daemon/Ratenotif.php @@ -12,7 +12,6 @@ class Ratenotif { require_once("datetime.php"); require_once('include/items.php'); - require_once('include/Contact.php'); if($argc < 3) return; -- cgit v1.2.3