X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fqueue.php;h=fb65d5c25bcbaf88e91815a98c2f9a11259a0473;hb=d28d2ff440efba47ad65cf28eab4be96e0ea05b2;hp=d4fc7dbd6277d0aa0cebd7fe198fa5a2efdc0d54;hpb=c26463b65b4b98f9aca77781fd74a7fe99f73814;p=friendica.git diff --git a/include/queue.php b/include/queue.php index d4fc7dbd62..fb65d5c25b 100644 --- a/include/queue.php +++ b/include/queue.php @@ -1,20 +1,6 @@ set_baseurl(get_config('system','url')); + load_hooks(); + $deadguys = array(); logger('queue: start'); @@ -58,17 +49,26 @@ function queue_run($argv, $argc){ 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']) ); @@ -97,7 +97,7 @@ function queue_run($argv, $argc){ $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); @@ -109,7 +109,7 @@ function queue_run($argv, $argc){ 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); @@ -120,6 +120,17 @@ function queue_run($argv, $argc){ 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; + } }