]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
Initial work adding oauth to api
[friendica.git] / include / items.php
index 2c23c6f1bdb7928b7bb2ed62ab30e44afbc52348..8dc997b16c77f2c5ec8ff58440d8b52b0a1b5a24 100644 (file)
@@ -730,6 +730,7 @@ function item_store($arr,$force_parent = false) {
        $arr['tag']           = ((x($arr,'tag'))           ? notags(trim($arr['tag']))           : '');
        $arr['attach']        = ((x($arr,'attach'))        ? notags(trim($arr['attach']))        : '');
        $arr['app']           = ((x($arr,'app'))           ? notags(trim($arr['app']))           : '');
+       $arr['origin']        = ((x($arr,'origin'))        ? intval($arr['origin'])              : 0 );
        $arr['guid']          = ((x($arr,'guid'))          ? notags(trim($arr['guid']))          : get_guid());
 
        if($arr['parent-uri'] === $arr['uri']) {
@@ -818,18 +819,10 @@ function item_store($arr,$force_parent = false) {
 
        // find the item we just created
 
-       $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1 ORDER BY `id` ASC",
+       $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC ",
                $arr['uri'],           // already dbesc'd
                intval($arr['uid'])
        );
-       if(! count($r)) {
-               // This is not good, but perhaps we encountered a rare race/cache condition, so back off and try again. 
-               sleep(3);
-               $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1 ORDER BY `id` ASC",
-                       $arr['uri'],           // already dbesc'd
-                       intval($arr['uid'])
-               );
-       }
 
        if(count($r)) {
                $current_post = $r[0]['id'];
@@ -1348,7 +1341,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
                                $parent_uri = $rawthread[0]['attribs']['']['ref'];
                        }
 
-                       if(($is_reply) && is_array($contact) && $pass != 1) {
+                       if(($is_reply) && is_array($contact)) {
+
+                               if($pass == 1)
+                                       continue;
 
                                // Have we seen it? If not, import it.
        
@@ -1873,13 +1869,14 @@ function local_delivery($importer,$data) {
 
                        $r = q("select `item`.`id`, `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` 
                                LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` 
-                               WHERE `contact`.`self` = 1 AND `item`.`wall` = 1 AND `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1",
+                               WHERE `contact`.`self` = 1 AND `item`.`wall` = 1 AND `item`.`uri` = '%s' AND `item`.`parent-uri` = '%s'
+                               AND `item`.`uid` = %d LIMIT 1",
+                               dbesc($parent_uri),
                                dbesc($parent_uri),
                                intval($importer['importer_uid'])
                        );
                        if($r && count($r)) {   
 
-
                                logger('local_delivery: received remote comment');
                                $is_like = false;
                                // remote reply to our post. Import and then notify everybody else.
@@ -2388,6 +2385,9 @@ function atom_entry($item,$type,$author,$owner,$comment = false) {
 
        $a = get_app();
 
+       if(! $item['parent'])
+               return;
+
        if($item['deleted'])
                return '<at:deleted-entry ref="' . xmlify($item['uri']) . '" when="' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '" />' . "\r\n";