]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
Merge pull request #9546 from annando/ostatus-notice
[friendica.git] / src / Protocol / OStatus.php
index e394877b354d85319d8e9f902d1720a5a8a3a15a..2cc815c3238ffb075ceb45ed050496a5a2af91a5 100644 (file)
@@ -482,7 +482,7 @@ class OStatus
                                Logger::log("Favorite ".$orig_uri." ".print_r($item, true));
 
                                $item["verb"] = Activity::LIKE;
-                               $item["parent-uri"] = $orig_uri;
+                               $item["thr-parent"] = $orig_uri;
                                $item["gravity"] = GRAVITY_ACTIVITY;
                                $item["object-type"] = Activity\ObjectType::NOTE;
                        }
@@ -495,7 +495,7 @@ class OStatus
                        self::processPost($xpath, $entry, $item, $importer);
 
                        if ($initialize && (count(self::$itemlist) > 0)) {
-                               if (self::$itemlist[0]['uri'] == self::$itemlist[0]['parent-uri']) {
+                               if (self::$itemlist[0]['uri'] == self::$itemlist[0]['thr-parent']) {
                                        // We will import it everytime, when it is started by our contacts
                                        $valid = Contact::isSharingByURL(self::$itemlist[0]['author-link'], self::$itemlist[0]['uid']);
 
@@ -522,11 +522,7 @@ class OStatus
                                                }
                                        }
                                } else {
-                                       // But we will only import complete threads
-                                       $valid = Item::exists(['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]);
-                                       if ($valid) {
-                                               Logger::log("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", Logger::DEBUG);
-                                       }
+                                       $valid = true;
                                }
 
                                if ($valid) {
@@ -621,7 +617,7 @@ class OStatus
                if (is_object($inreplyto->item(0))) {
                        foreach ($inreplyto->item(0)->attributes as $attributes) {
                                if ($attributes->name == "ref") {
-                                       $item["parent-uri"] = $attributes->textContent;
+                                       $item["thr-parent"] = $attributes->textContent;
                                }
                                if ($attributes->name == "href") {
                                        $related = $attributes->textContent;
@@ -702,16 +698,16 @@ class OStatus
                        self::fetchConversation($item['conversation-href'], $item['conversation-uri']);
                }
 
-               if (isset($item["parent-uri"])) {
-                       if (!Item::exists(['uid' => $importer["uid"], 'uri' => $item['parent-uri']])) {
+               if (isset($item["thr-parent"])) {
+                       if (!Item::exists(['uid' => $importer["uid"], 'uri' => $item['thr-parent']])) {
                                if ($related != '') {
-                                       self::fetchRelated($related, $item["parent-uri"], $importer);
+                                       self::fetchRelated($related, $item["thr-parent"], $importer);
                                }
                        } else {
                                Logger::log('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', Logger::DEBUG);
                        }
                } else {
-                       $item["parent-uri"] = $item["uri"];
+                       $item["thr-parent"] = $item["uri"];
                        $item["gravity"] = GRAVITY_PARENT;
                }
 
@@ -1074,7 +1070,7 @@ class OStatus
                if (is_object($inreplyto->item(0))) {
                        foreach ($inreplyto->item(0)->attributes as $attributes) {
                                if ($attributes->name == "ref") {
-                                       $item["parent-uri"] = $attributes->textContent;
+                                       $item["thr-parent"] = $attributes->textContent;
                                }
                        }
                }
@@ -1126,8 +1122,8 @@ class OStatus
                                                break;
                                        case "related":
                                                if ($item["object-type"] != Activity\ObjectType::BOOKMARK) {
-                                                       if (!isset($item["parent-uri"])) {
-                                                               $item["parent-uri"] = $attribute['href'];
+                                                       if (!isset($item["thr-parent"])) {
+                                                               $item["thr-parent"] = $attribute['href'];
                                                        }
                                                        $link_data['related'] = $attribute['href'];
                                                } else {
@@ -1934,9 +1930,8 @@ class OStatus
 
                if ($item['gravity'] != GRAVITY_PARENT) {
                        $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
-                       $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
 
-                       $thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $parent_item]);
+                       $thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
 
                        if (DBA::isResult($thrparent)) {
                                $mentioned[$thrparent["author-link"]] = $thrparent["author-link"];
@@ -1949,7 +1944,7 @@ class OStatus
                        }
 
                        $attributes = [
-                                       "ref" => $parent_item,
+                                       "ref" => $item['thr-parent'],
                                        "href" => $parent_plink];
                        XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
 
@@ -1960,7 +1955,7 @@ class OStatus
                }
 
                if (intval($item['parent']) > 0) {
-                       $conversation_href = $conversation_uri = str_replace('/objects/', '/context/', $item['parent-uri']);
+                       $conversation_href = $conversation_uri = str_replace('/objects/', '/context/', $item['thr-parent']);
 
                        if (isset($parent_item)) {
                                $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]);