diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-12-16 22:42:33 -0800 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-12-16 22:42:33 -0800 |
commit | 4cacfe59bd2f2d3b41ec9173b9310039971a76c8 (patch) | |
tree | b8c29d6e283e2391923b20c9515a52a1fa652388 /include/deliver.php | |
parent | b909c878b1a58b055935a797d2a062b22ffc4315 (diff) | |
download | volse-hubzilla-4cacfe59bd2f2d3b41ec9173b9310039971a76c8.tar.gz volse-hubzilla-4cacfe59bd2f2d3b41ec9173b9310039971a76c8.tar.bz2 volse-hubzilla-4cacfe59bd2f2d3b41ec9173b9310039971a76c8.zip |
queue/notification/delivery refactor continued
Diffstat (limited to 'include/deliver.php')
-rw-r--r-- | include/deliver.php | 91 |
1 files changed, 6 insertions, 85 deletions
diff --git a/include/deliver.php b/include/deliver.php index cef8f7912..60d935d02 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -16,7 +16,6 @@ function deliver_run($argv, $argc) { logger('deliver: invoked: ' . print_r($argv,true), LOGGER_DATA); - for($x = 1; $x < $argc; $x ++) { $dresult = null; @@ -25,76 +24,6 @@ function deliver_run($argv, $argc) { ); if($r) { - /** - * Check to see if we have any recent communications with this hub (in the last month). - * If not, reduce the outq_priority. - */ - - $base = ''; - - $h = parse_url($r[0]['outq_posturl']); - if($h) { - $base = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : ''); - if($base !== z_root()) { - $y = q("select site_update, site_dead from site where site_url = '%s' ", - dbesc($base) - ); - if($y) { - if(intval($y[0]['site_dead'])) { - remove_queue_by_posturl($r[0]['outq_posturl']); - logger('dead site ignored ' . $base); - continue; - } - if($y[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) { - update_queue_item($r[0]['outq_hash'],10); - logger('immediate delivery deferred for site ' . $base); - continue; - } - } - else { - - // zot sites should all have a site record, unless they've been dead for as long as - // your site has existed. Since we don't know for sure what these sites are, - // call them unknown - - q("insert into site (site_url, site_update, site_dead, site_type) values ('%s','%s',0,%d) ", - dbesc($base), - dbesc(datetime_convert()), - intval(($r[0]['outq_driver'] === 'post') ? SITE_TYPE_NOTZOT : SITE_TYPE_UNKNOWN) - ); - } - } - } - - // "post" queue driver - used for diaspora and friendica-over-diaspora communications. - - if($r[0]['outq_driver'] === 'post') { - - - $result = z_post_url($r[0]['outq_posturl'],$r[0]['outq_msg']); - if($result['success'] && $result['return_code'] < 300) { - logger('deliver: queue post success to ' . $r[0]['outq_posturl'], LOGGER_DEBUG); - if($base) { - q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' ", - dbesc(datetime_convert()), - dbesc($base) - ); - } - q("update dreport set dreport_result = '%s', dreport_time = '%s' where dreport_queue = '%s' limit 1", - dbesc('accepted for delivery'), - dbesc(datetime_convert()), - dbesc($argv[$x]) - ); - - remove_queue_item($argv[$x]); - } - else { - logger('deliver: queue post returned ' . $result['return_code'] . ' from ' . $r[0]['outq_posturl'],LOGGER_DEBUG); - update_queue_item($argv[$x]); - } - continue; - } - $notify = json_decode($r[0]['outq_notify'],true); // Messages without an outq_msg will need to go via the web, even if it's a @@ -118,7 +47,7 @@ function deliver_run($argv, $argc) { $dresult = zot_import($msg,z_root()); } - remove_queue_item($argv[$x]); + remove_queue_item($r[0]['outq_hash']); if($dresult && is_array($dresult)) { foreach($dresult as $xx) { @@ -142,19 +71,11 @@ function deliver_run($argv, $argc) { ); } } - else { - logger('deliver: dest: ' . $r[0]['outq_posturl'], LOGGER_DEBUG); - $result = zot_zot($r[0]['outq_posturl'],$r[0]['outq_notify']); - if($result['success']) { - logger('deliver: remote zot delivery succeeded to ' . $r[0]['outq_posturl']); - zot_process_response($r[0]['outq_posturl'],$result, $r[0]); - } - else { - logger('deliver: remote zot delivery failed to ' . $r[0]['outq_posturl']); - logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); - update_queue_item($argv[$x],10); - } - } + + // otherwise it's a remote delivery - call queue_deliver(); + + queue_deliver($r[0],true); + } } } |