$queue_id = 0;
$deadguys = array();
+ $deadservers = array();
+ $serverlist = array();
logger('queue: start');
// For the first 12 hours we'll try to deliver every 15 minutes
// After that, we'll only attempt delivery once per hour.
- $r = q("SELECT `id` FROM `queue` WHERE (( `created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR && `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ) OR ( `last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR ))");
+ $r = q("SELECT `id` FROM `queue` WHERE ((`created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR && `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE) OR (`last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR)) ORDER BY `cid`, `created`");
}
if(! $r){
return;
// so check again if this entry still needs processing
if($queue_id) {
- $qi = q("select * from queue where `id` = %d limit 1",
+ $qi = q("SELECT * FROM `queue` WHERE `id` = %d LIMIT 1",
intval($queue_id)
);
}
continue;
}
- if (!poco_reachable($c[0]['url'])) {
- logger('queue: skipping probably dead url: ' . $c[0]['url']);
+ $server = poco_detect_server($c[0]['url']);
+
+ if (($server != "") AND !in_array($server, $serverlist)) {
+ logger("Check server ".$server." (".$c[0]["network"].")");
+ if (!poco_check_server($server, $c[0]["network"], true))
+ $deadservers[] = $server;
+
+ $serverlist[] = $server;
+ }
+
+ if (($server != "") AND in_array($server, $deadservers)) {
+ logger('queue: skipping known dead server: '.$server);
update_queue_time($q_item['id']);
continue;
}
switch($contact['network']) {
case NETWORK_DFRN:
- logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
+ logger('queue: dfrndelivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
$deliver_status = dfrn_deliver($owner,$contact,$data);
if($deliver_status == (-1)) {
update_queue_time($q_item['id']);
$deadguys[] = $contact['notify'];
- }
- else {
+ } else
remove_queue_item($q_item['id']);
- }
+
break;
case NETWORK_OSTATUS:
if($contact['notify']) {
- logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
+ logger('queue: slapdelivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
$deliver_status = slapper($owner,$contact['notify'],$data);
- if($deliver_status == (-1))
+ if($deliver_status == (-1)) {
update_queue_time($q_item['id']);
- else
+ $deadguys[] = $contact['notify'];
+ } else
remove_queue_item($q_item['id']);
}
break;
case NETWORK_DIASPORA:
if($contact['notify']) {
- logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
+ logger('queue: diaspora_delivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
$deliver_status = diaspora_transmit($owner,$contact,$data,$public,true);
- if($deliver_status == (-1))
+ if($deliver_status == (-1)) {
update_queue_time($q_item['id']);
- else
+ $deadguys[] = $contact['notify'];
+ } else
remove_queue_item($q_item['id']);
+
}
break;
break;
}
+ logger('Deliver status '.$deliver_status.' for item '.$q_item['id'].' to '.$contact['name'].' <'.$contact['url'].'>');
}
return;
// Test for Diaspora
$serverret = z_fetch_url($server_url);
- $lines = explode("\n",$serverret["header"]);
- if(count($lines))
- foreach($lines as $line) {
- $line = trim($line);
- if(stristr($line,'X-Diaspora-Version:')) {
- $platform = "Diaspora";
- $version = trim(str_replace("X-Diaspora-Version:", "", $line));
- $version = trim(str_replace("x-diaspora-version:", "", $version));
- $network = NETWORK_DIASPORA;
- $versionparts = explode("-", $version);
- $version = $versionparts[0];
+ if (!$serverret["success"] OR ($serverret["body"] == ""))
+ $failure = true;
+ else {
+ $lines = explode("\n",$serverret["header"]);
+ if(count($lines))
+ foreach($lines as $line) {
+ $line = trim($line);
+ if(stristr($line,'X-Diaspora-Version:')) {
+ $platform = "Diaspora";
+ $version = trim(str_replace("X-Diaspora-Version:", "", $line));
+ $version = trim(str_replace("x-diaspora-version:", "", $version));
+ $network = NETWORK_DIASPORA;
+ $versionparts = explode("-", $version);
+ $version = $versionparts[0];
+ }
}
- }
+ }
}
if (!$failure) {