]> git.mxchange.org Git - friendica.git/blobdiff - include/delivery.php
string update
[friendica.git] / include / delivery.php
index e06db6d975ef504dbdf4495e2cf029df5b944edd..5441ac5108c5bfdc892ea91749930189b189c33a 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 require_once("boot.php");
+require_once('include/queue_fn.php');
 
 function delivery_run($argv, $argc){
        global $a, $db;
@@ -240,7 +241,7 @@ function delivery_run($argv, $argc){
                                $birthday = '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>';
 
                        $atom .= replace_macros($feed_template, array(
-                                       '$version'      => xmlify(FRIENDIKA_VERSION),
+                                       '$version'      => xmlify(FRIENDICA_VERSION),
                                        '$feed_id'      => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname'] ),
                                        '$feed_title'   => xmlify($owner['name']),
                                        '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) ,
@@ -269,7 +270,7 @@ function delivery_run($argv, $argc){
                                        continue;
 
                                if($normal_mode) {
-                                       if($item_id == $item['id'])
+                                       if($item_id == $item['id'] || $item['id'] == $item['parent'])
                                                $atom .= atom_entry($item,'text',$item_contact,$owner,true);
                                }
                                else
@@ -280,6 +281,42 @@ function delivery_run($argv, $argc){
                        $atom .= '</feed>' . "\r\n";
 
                        logger('notifier: ' . $atom, LOGGER_DATA);
+                       $basepath =  implode('/', array_slice(explode('/',$contact['url']),0,3));
+
+                       // perform local delivery if we are on the same site
+
+                       if(link_compare($basepath,$a->get_baseurl())) {
+
+                               $nickname = basename($contact['url']);
+                               if($contact['issued-id'])
+                                       $sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
+                               else
+                                       $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
+                                       
+                               $x = q("SELECT  `contact`.*, `contact`.`uid` AS `importer_uid`, 
+                                       `contact`.`pubkey` AS `cpubkey`, 
+                                       `contact`.`prvkey` AS `cprvkey`, 
+                                       `contact`.`thumb` AS `thumb`, 
+                                       `contact`.`url` as `url`,
+                                       `contact`.`name` as `senderName`,
+                                       `user`.* 
+                                       FROM `contact` 
+                                       LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` 
+                                       WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+                                       AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'
+                                       $sql_extra
+                                       AND `user`.`account_expired` = 0 LIMIT 1",
+                                       dbesc(NETWORK_DFRN),
+                                       dbesc($nickname)
+                               );
+
+                               if(count($x)) {
+                                       require_once('library/simplepie/simplepie.inc');
+                                       logger('mod-delivery: local delivery');
+                                       local_delivery($x[0],$atom);
+                                       break;                                  
+                               }
+                       }
 
                        $deliver_status = dfrn_deliver($owner,$contact,$atom);
 
@@ -287,14 +324,7 @@ function delivery_run($argv, $argc){
        
                        if($deliver_status == (-1)) {
                                logger('notifier: delivery failed: queuing message');
-                               // queue message for redelivery
-                               q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`)
-                                       VALUES ( %d, '%s', '%s', '%s') ",
-                                       intval($contact['id']),
-                                       dbesc(datetime_convert()),
-                                       dbesc(datetime_convert()),
-                                       dbesc($atom)
-                               );
+                               add_to_queue($contact['id'],NETWORK_DFRN,$atom);
                        }
                        break;
 
@@ -334,13 +364,7 @@ function delivery_run($argv, $argc){
                                                $deliver_status = slapper($owner,$contact['notify'],$slappy);
                                                if($deliver_status == (-1)) {
                                                        // queue message for redelivery
-                                                       q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`)
-                                                               VALUES ( %d, '%s', '%s', '%s') ",
-                                                               intval($contact['id']),
-                                                               dbesc(datetime_convert()),
-                                                               dbesc(datetime_convert()),
-                                                               dbesc($slappy)
-                                                       );                                                              
+                                                       add_to_queue($contact['id'],NETWORK_OSTATUS,$slappy);
                                                }
                                        }
                                }