]> git.mxchange.org Git - friendica.git/commitdiff
infrastructure for queueing, redelivery
authorFriendika <info@friendika.com>
Mon, 22 Nov 2010 07:00:01 +0000 (23:00 -0800)
committerFriendika <info@friendika.com>
Mon, 22 Nov 2010 07:00:01 +0000 (23:00 -0800)
boot.php
database.sql
include/items.php
include/notifier.php
include/salmon.php
mod/install.php
update.php

index f03a5be20fc0253dc2ade7db172d0990e7bb5aab..b55c3198bcc492012a7a6e2e65991bcb877b47aa 100644 (file)
--- 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
index a0b121b0a6c61827138dc8607f1b6db44adebbbf..ea1523e2898107e8490f3ca445dfe4e14631e535 100644 (file)
@@ -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;
index 584236f78001f41c0abcc04415f6ae69525319be..b5e901c91131c236b908acc80dcd2fb20bbda4fc 100644 (file)
@@ -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);
 
index f22917e4ffd4d0d56b9a8b91f7fee31f3b913a86..bbc4f00474364860752edd5acf99bae3160b57ce 100644 (file)
                        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 {
 
                                                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
+                                                                       
+                                                               }
                                                        }
                                                }
                                        }
                                break;
                }
 
+
                if(($cmd === 'mail') && ($deliver_status == 0)) {
                        $r = q("UPDATE `mail` SET `delivered` = 1 WHERE `id` = %d LIMIT 1",
                                intval($item_id)
                        logger('notifier: urldelivery: ' . $url);
                        foreach($slaps as $slappy) {
                                if($url) {
-                                       slapper($owner,$url,$slappy);
+                                       $deliver_status = slapper($owner,$url,$slappy);
                                }
                        }
                }
index a12b7391e06cdf7a59273d2db18d5cd144bfe6e3..85bda1c8f314afad412b2255ac8a61bf725b8edc 100644 (file)
@@ -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);
 }
 
index 7f150ef1dcaa65327beadbdf94fefc16a2b4d482..cbe3b2fc9b190995c2cbf0c611362bd49edbe551 100644 (file)
@@ -173,6 +173,6 @@ function load_database($db) {
                                $errors ++;
                        }
                }
-        }
+       }
        return $errors;
 }
\ No newline at end of file
index c4995604e758e802d20eb94cd5c78c0fbbf271d3..57020966ffa94a5f14d22144d7d91228bcef1b7e 100644 (file)
@@ -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 ");
+}