aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2010-11-21 23:00:01 -0800
committerFriendika <info@friendika.com>2010-11-21 23:00:01 -0800
commitde6c777d3f6753b8fb5f33bc0ee8acafc6772551 (patch)
treeef95d120dd770da99071b195fdc08626981cc639
parent552c56102ea70c6c9e32e13675b564a36814a069 (diff)
downloadvolse-hubzilla-de6c777d3f6753b8fb5f33bc0ee8acafc6772551.tar.gz
volse-hubzilla-de6c777d3f6753b8fb5f33bc0ee8acafc6772551.tar.bz2
volse-hubzilla-de6c777d3f6753b8fb5f33bc0ee8acafc6772551.zip
infrastructure for queueing, redelivery
-rw-r--r--boot.php12
-rw-r--r--database.sql7
-rw-r--r--include/items.php5
-rw-r--r--include/notifier.php27
-rw-r--r--include/salmon.php4
-rw-r--r--mod/install.php2
-rw-r--r--update.php9
7 files changed, 53 insertions, 13 deletions
diff --git a/boot.php b/boot.php
index f03a5be20..b55c3198b 100644
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
set_time_limit(0);
-define ( 'BUILD_ID', 1018 );
+define ( 'BUILD_ID', 1019 );
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
define ( 'EOL', "<br />\r\n" );
@@ -378,8 +378,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
$curl_time = intval(get_config('system','curl_timeout'));
- if($curl_time)
- curl_setopt($ch, CURLOPT_TIMEOUT, $curl_time);
+ curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
// by default we will allow self-signed certs
// but you can override this
@@ -400,7 +399,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
$s = curl_exec($ch);
- $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ $http_code = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
$header = substr($s,0,strpos($s,"\r\n\r\n"));
if(stristr($header,'100') && (strlen($header) < 30)) {
// 100 Continue has two headers, get the real one
@@ -440,8 +439,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0) {
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
$curl_time = intval(get_config('system','curl_timeout'));
- if($curl_time)
- curl_setopt($ch, CURLOPT_TIMEOUT, $curl_time);
+ curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
if(is_array($headers))
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
@@ -459,7 +457,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0) {
$s = curl_exec($ch);
- $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ $http_code = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
$header = substr($s,0,strpos($s,"\r\n\r\n"));
if(stristr($header,'100') && (strlen($header) < 30)) {
// 100 Continue has two headers, get the real one
diff --git a/database.sql b/database.sql
index a0b121b0a..ea1523e28 100644
--- a/database.sql
+++ b/database.sql
@@ -408,3 +408,10 @@ CREATE TABLE IF NOT EXISTS `auth_codes` (
PRIMARY KEY ( `id` )
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+CREATE TABLE IF NOT EXISTS `queue` (
+`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+`cid` INT NOT NULL ,
+`created` DATETIME NOT NULL ,
+`last` DATETIME NOT NULL ,
+`content` MEDIUMTEXT NOT NULL
+) ENGINE = MYISAM DEFAULT CHARSET=utf8;
diff --git a/include/items.php b/include/items.php
index 584236f78..b5e901c91 100644
--- a/include/items.php
+++ b/include/items.php
@@ -710,7 +710,10 @@ function dfrn_deliver($owner,$contact,$atom) {
$xml = post_url($contact['notify'],$postvars);
- logger('dfrn_deliver: ' . "SENDING: " . print_r($postvars,true) . "\n" . "RECEIVING: " . $xml);
+ logger('dfrn_deliver: ' . "SENDING: " . print_r($postvars,true) . "\n" . "RECEIVING: " . $xml, LOGGER_DATA);
+
+ if(! strlen($xml))
+ return(-1);
$res = simplexml_load_string($xml);
diff --git a/include/notifier.php b/include/notifier.php
index f22917e4f..bbc4f0047 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -255,10 +255,24 @@
case 'dfrn':
logger('notifier: dfrndelivery: ' . $contact['name']);
$deliver_status = dfrn_deliver($owner,$contact,$atom);
+
+ if($deliver_status == (-1)) {
+ // queue message for redelivery
+
+ }
+
break;
default:
if($followup && $contact['notify']) {
- slapper($owner,$contact['notify'],$slap);
+ logger('notifier: slapdelivery: ' . $contact['name']);
+ $deliver_status = slapper($owner,$contact['notify'],$slap);
+
+ if($deliver_status == (-1)) {
+ // queue message for redelivery
+
+ }
+
+
}
else {
@@ -269,7 +283,13 @@
logger('notifier: slapdelivery: ' . $contact['name']);
foreach($slaps as $slappy) {
if($contact['notify']) {
- slapper($owner,$contact['notify'],$slappy);
+ $deliver_status = slapper($owner,$contact['notify'],$slappy);
+ if($deliver_status == (-1)) {
+ // queue message for redelivery
+ // if not already in queue
+ // else if deliver_status ok and queued, remove from queue
+
+ }
}
}
}
@@ -277,6 +297,7 @@
break;
}
+
if(($cmd === 'mail') && ($deliver_status == 0)) {
$r = q("UPDATE `mail` SET `delivered` = 1 WHERE `id` = %d LIMIT 1",
intval($item_id)
@@ -292,7 +313,7 @@
logger('notifier: urldelivery: ' . $url);
foreach($slaps as $slappy) {
if($url) {
- slapper($owner,$url,$slappy);
+ $deliver_status = slapper($owner,$url,$slappy);
}
}
}
diff --git a/include/salmon.php b/include/salmon.php
index a12b7391e..85bda1c8f 100644
--- a/include/salmon.php
+++ b/include/salmon.php
@@ -205,6 +205,8 @@ EOT;
}
logger('slapper returned ' . $return_code);
- return;
+ if(! $return_code)
+ return(-1);
+ return ((substr($return_code,0,1) === '2') ? 0 : 1);
}
diff --git a/mod/install.php b/mod/install.php
index 7f150ef1d..cbe3b2fc9 100644
--- a/mod/install.php
+++ b/mod/install.php
@@ -173,6 +173,6 @@ function load_database($db) {
$errors ++;
}
}
- }
+ }
return $errors;
} \ No newline at end of file
diff --git a/update.php b/update.php
index c4995604e..57020966f 100644
--- a/update.php
+++ b/update.php
@@ -167,3 +167,12 @@ PRIMARY KEY ( `id` )
}
+function update_1018() {
+ q("CREATE TABLE IF NOT EXISTS `queue` (
+`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+`cid` INT NOT NULL ,
+`created` DATETIME NOT NULL ,
+`last` DATETIME NOT NULL ,
+`content` MEDIUMTEXT NOT NULL
+) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
+}