X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fqueue.php;h=fb65d5c25bcbaf88e91815a98c2f9a11259a0473;hb=d28d2ff440efba47ad65cf28eab4be96e0ea05b2;hp=96ddfa81bc143df6fb2def04ae0111502abbb22d;hpb=e15b1a87555caecef902b975349a9a930f9bb0e7;p=friendica.git diff --git a/include/queue.php b/include/queue.php index 96ddfa81bc..fb65d5c25b 100644 --- a/include/queue.php +++ b/include/queue.php @@ -1,29 +1,20 @@ set_baseurl(get_config('system','url')); + load_hooks(); + $deadguys = array(); logger('queue: start'); @@ -50,20 +46,29 @@ function remove_queue_item($id) { $r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE "); - if(! count($r)) - killme(); + if(! count($r)){ + return; + } + + call_hooks('queue_predeliver', $a, $r); + // delivery loop require_once('include/salmon.php'); foreach($r as $q_item) { - $qi = q("SELECT * FROM `queue` WHERE `id` = %d LIMIT 1", + + // queue_predeliver hooks may have changed the queue db details, + // so check again if this entry still needs processing + + $qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ", intval($q_item['id']) ); if(! count($qi)) continue; + $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($qi[0]['cid']) ); @@ -92,7 +97,7 @@ function remove_queue_item($id) { $deliver_status = 0; switch($contact['network']) { - case 'dfrn': + case NETWORK_DFRN: logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name']); $deliver_status = dfrn_deliver($owner,$contact,$data); @@ -104,7 +109,7 @@ function remove_queue_item($id) { remove_queue_item($q_item['id']); } break; - default: + case NETWORK_OSTATUS: if($contact['notify']) { logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name']); $deliver_status = slapper($owner,$contact['notify'],$data); @@ -115,10 +120,25 @@ function remove_queue_item($id) { remove_queue_item($q_item['id']); } break; + default: + $params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false); + call_hooks('queue_deliver', $a, $params); + + if($params['result']) + remove_queue_item($q_item['id']); + else + update_queue_time($q_item['id']); + + break; + } } - killme(); + return; - // NOTREACHED +} +if (array_search(__file__,get_included_files())===0){ + queue_run($argv,$argc); + killme(); +}