diff options
author | mrjive <mrjive@mrjive.it> | 2015-01-06 15:13:03 +0100 |
---|---|---|
committer | mrjive <mrjive@mrjive.it> | 2015-01-06 15:13:03 +0100 |
commit | b80c218606994032e76805900cb9b340ea132358 (patch) | |
tree | bf625cf4c59bf521e639018399bf1770d116a6a0 /include/deliver.php | |
parent | aa6d61d3b19cb13c30bf5a1579adefedf0cc9515 (diff) | |
parent | 3185bfe3ca131d471b8fcdc0c94abf1a114486c7 (diff) | |
download | volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.gz volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.bz2 volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.zip |
Merge pull request #1 from friendica/master
test pull request
Diffstat (limited to 'include/deliver.php')
-rw-r--r-- | include/deliver.php | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/include/deliver.php b/include/deliver.php index 0ad008c23..47d8562df 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -20,16 +20,52 @@ function deliver_run($argv, $argc) { dbesc($argv[$x]) ); if($r) { - if($r[0]['outq_posturl'] === z_root() . '/post') { + 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); + $y = q("delete from outq where outq_hash = '%s'", + dbesc($argv[$x]) + ); + } + else { + logger('deliver: queue post returned ' . $result['return_code'] . ' from ' . $r[0]['outq_posturl'],LOGGER_DEBUG); + $y = q("update outq set outq_updated = '%s' where outq_hash = '%s'", + dbesc(datetime_convert()), + dbesc($argv[$x]) + ); + } + continue; + } + + $notify = json_decode($r[0]['outq_notify'],true); + + // Check if this is a conversation request packet. It won't have outq_msg + // but will be an encrypted packet - so will need to be handed off to + // web delivery rather than processed inline. + + $sendtoweb = false; + if(array_key_exists('iv',$notify) && (! $r[0]['outq_msg'])) + $sendtoweb = true; + + if(($r[0]['outq_posturl'] === z_root() . '/post') && (! $sendtoweb)) { logger('deliver: local delivery', LOGGER_DEBUG); // local delivery // we should probably batch these and save a few delivery processes - // If there is no outq_msg, this is a refresh_all message which does not require local handling - if($r[0]['outq_msg']) { - $msg = array('body' => json_encode(array('pickup' => array(array('notify' => json_decode($r[0]['outq_notify'],true),'message' => json_decode($r[0]['outq_msg'],true)))))); - zot_import($msg,z_root()); - $r = q("delete from outq where outq_hash = '%s' limit 1", + if($r[0]['outq_msg']) { + $m = json_decode($r[0]['outq_msg'],true); + if(array_key_exists('message_list',$m)) { + foreach($m['message_list'] as $mm) { + $msg = array('body' => json_encode(array('pickup' => array(array('notify' => $notify,'message' => $mm))))); + zot_import($msg,z_root()); + } + } + else { + $msg = array('body' => json_encode(array('pickup' => array(array('notify' => $notify,'message' => $m))))); + zot_import($msg,z_root()); + } + $r = q("delete from outq where outq_hash = '%s'", dbesc($argv[$x]) ); } @@ -41,7 +77,7 @@ function deliver_run($argv, $argc) { zot_process_response($r[0]['outq_posturl'],$result, $r[0]); } else { - $y = q("update outq set outq_updated = '%s' where outq_hash = '%s' limit 1", + $y = q("update outq set outq_updated = '%s' where outq_hash = '%s'", dbesc(datetime_convert()), dbesc($argv[$x]) ); |