2 require_once("boot.php");
3 require_once('include/queue_fn.php');
5 function queue_run($argv, $argc){
13 @include(".htconfig.php");
14 require_once("dba.php");
15 $db = new dba($db_host, $db_user, $db_pass, $db_data);
16 unset($db_host, $db_user, $db_pass, $db_data);
20 require_once("session.php");
21 require_once("datetime.php");
22 require_once('include/items.php');
23 require_once('include/bbcode.php');
25 load_config('config');
26 load_config('system');
28 $a->set_baseurl(get_config('system','url'));
34 logger('queue: start');
36 $r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
37 LEFT JOIN `contact` ON `queue`.`cid` = `contact`.`id`
38 WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
41 logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
42 logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
44 q("DELETE FROM `queue` WHERE `created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
47 $r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ");
53 call_hooks('queue_predeliver', $a, $r);
58 require_once('include/salmon.php');
59 require_once('include/diaspora.php');
61 foreach($r as $q_item) {
63 // queue_predeliver hooks may have changed the queue db details,
64 // so check again if this entry still needs processing
66 $qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ",
73 $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
77 remove_queue_item($q_item['id']);
80 if(in_array($c[0]['notify'],$deadguys)) {
81 logger('queue: skipping known dead url: ' . $c[0]['notify']);
82 update_queue_time($q_item['id']);
86 $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
90 remove_queue_item($q_item['id']);
94 $data = $qi[0]['content'];
100 switch($contact['network']) {
102 logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
103 $deliver_status = dfrn_deliver($owner,$contact,$data);
105 if($deliver_status == (-1)) {
106 update_queue_time($q_item['id']);
107 $deadguys[] = $contact['notify'];
110 remove_queue_item($q_item['id']);
113 case NETWORK_OSTATUS:
114 if($contact['notify']) {
115 logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
116 $deliver_status = slapper($owner,$contact['notify'],$data);
118 if($deliver_status == (-1))
119 update_queue_time($q_item['id']);
121 remove_queue_item($q_item['id']);
124 case NETWORK_DIASPORA:
125 if($contact['notify']) {
126 logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
127 $deliver_status = diaspora_transmit($owner,$contact['notify'],$data);
129 if($deliver_status == (-1))
130 update_queue_time($q_item['id']);
132 remove_queue_item($q_item['id']);
137 $params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false);
138 call_hooks('queue_deliver', $a, $params);
140 if($params['result'])
141 remove_queue_item($q_item['id']);
143 update_queue_time($q_item['id']);
154 if (array_search(__file__,get_included_files())===0){
155 queue_run($argv,$argc);