]> git.mxchange.org Git - friendica.git/commitdiff
Threaded comments will now be transmitted
authorMichael <heluecht@pirati.ca>
Tue, 27 Dec 2016 14:37:48 +0000 (14:37 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 27 Dec 2016 14:37:48 +0000 (14:37 +0000)
include/diaspora.php

index 77ca376b7d82ba9c2e82f3334416dd90d3e713ce..9b00f6ce6a58315269b1c17edb711444e1dd47bb 100644 (file)
@@ -1145,16 +1145,20 @@ class Diaspora {
         *
         * @param string $author Author handle
         * @param string $guid Message guid
+        * @param boolean $onlyfound Only return uri when found in the database
         *
         * @return string The constructed uri or the one from our database
         */
-       private function get_uri_from_guid($author, $guid) {
+       private static function get_uri_from_guid($author, $guid, $onlyfound = false) {
 
                $r = q("SELECT `uri` FROM `item` WHERE `guid` = '%s' LIMIT 1", dbesc($guid));
-               if ($r)
+               if (dbm::is_result($r)) {
                        return $r[0]["uri"];
-               else
+               } elseif (!$onlyfound) {
                        return $author.":".$guid;
+               }
+
+               return "";
        }
 
        /**
@@ -1196,6 +1200,13 @@ class Diaspora {
                        $created_at = datetime_convert();
                }
 
+               if (isset($data->thread_parent_guid)) {
+                       $thread_parent_guid = notags(unxmlify($data->thread_parent_guid));
+                       $thr_uri = self::get_uri_from_guid("", $thread_parent_guid, true);
+               } else {
+                       $thr_uri = "";
+               }
+
                $contact = self::allowed_contact_by_handle($importer, $sender, true);
                if (!$contact) {
                        return false;
@@ -1240,7 +1251,12 @@ class Diaspora {
                $datarray["type"] = "remote-comment";
                $datarray["verb"] = ACTIVITY_POST;
                $datarray["gravity"] = GRAVITY_COMMENT;
-               $datarray["parent-uri"] = $parent_item["uri"];
+
+               if ($thr_uri != "") {
+                       $datarray["parent-uri"] = $thr_uri;
+               } else {
+                       $datarray["parent-uri"] = $parent_item["uri"];
+               }
 
                $datarray["object-type"] = ACTIVITY_OBJ_COMMENT;
                $datarray["object"] = $xml;