]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Some corrections
[friendica.git] / src / Protocol / Diaspora.php
index b25809a0e5f87552491ac75eb247d90b128c1049..981abb0831defaec2816419afe5ec16b307cbc7b 100644 (file)
@@ -68,6 +68,12 @@ class Diaspora
                }
 
                if (Config::get("system", "relay_directly", false)) {
+                       // We distribute our stuff based on the parent to ensure that the thread will be complete
+                       $parent = dba::selectFirst('item', ['parent'], ['id' => $item_id]);
+                       if (!DBM::is_result($parent)) {
+                               return;
+                       }
+
                        // Servers that want to get all content
                        $servers = dba::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'all']);
                        while ($server = dba::fetch($servers)) {
@@ -75,7 +81,7 @@ class Diaspora
                        }
 
                        // All tags of the current post
-                       $condition = ['otype' => TERM_OBJ_POST, 'type' => TERM_HASHTAG, 'oid' => $item_id];
+                       $condition = ['otype' => TERM_OBJ_POST, 'type' => TERM_HASHTAG, 'oid' => $parent['parent']];
                        $tags = dba::select('term', ['term'], $condition);
                        $taglist = [];
                        while ($tag = dba::fetch($tags)) {
@@ -1602,34 +1608,9 @@ class Diaspora
                logger('Contacts are updated.');
 
                // update items
-               /// @todo This is an extreme performance killer
-               $fields = [
-                       'owner-link' => [$contact["url"], $data["url"]],
-                       'author-link' => [$contact["url"], $data["url"]],
-               ];
-               foreach ($fields as $n => $f) {
-                       $r = q(
-                               "SELECT `id` FROM `item` WHERE `%s` = '%s' AND `uid` = %d LIMIT 1",
-                               $n,
-                               dbesc($f[0]),
-                               intval($importer["uid"])
-                       );
-
-                       if (DBM::is_result($r)) {
-                               $x = q(
-                                       "UPDATE `item` SET `%s` = '%s' WHERE `%s` = '%s' AND `uid` = %d",
-                                       $n,
-                                       dbesc($f[1]),
-                                       $n,
-                                       dbesc($f[0]),
-                                       intval($importer["uid"])
-                               );
-
-                               if ($x === false) {
-                                       return false;
-                               }
-                       }
-               }
+               // This is an extreme performance killer
+               Item::update(['owner-link' => $data["url"]], ['owner-link' => $contact["url"], 'uid' => $importer["uid"]]);
+               Item::update(['author-link' => $data["url"]], ['author-link' => $contact["url"], 'uid' => $importer["uid"]]);
 
                logger('Items are updated.');
 
@@ -2988,12 +2969,10 @@ class Diaspora
                        case "StatusMessage":
                                return self::itemRetraction($importer, $contact, $data);
 
-                       case "Contact":
-                       case "Person":
-                               /// @todo What should we do with an "unshare"?
-                               // Removing the contact isn't correct since we still can read the public items
-                               Contact::remove($contact["id"]);
-                               return true;
+                       case "PollParticipation":
+                       case "Photo":
+                               // Currently unsupported
+                               break;
 
                        default:
                                logger("Unknown target type ".$target_type);
@@ -3590,8 +3569,12 @@ class Diaspora
                                $ret["root_guid"] = $guid;
                                return $ret;
                        }
+               } elseif (($guid == "") && $complete) {
+                       return false;
                }
 
+               $ret["root_guid"] = $guid;
+
                $profile = "";
                preg_match("/profile='(.*?)'/ism", $attributes, $matches);
                if ($matches[1] != "") {
@@ -3612,10 +3595,6 @@ class Diaspora
                        }
                }
 
-               if (!empty($guid)) {
-                       $ret["root_guid"] = $guid;
-               }
-
                if (empty($ret) && !$complete) {
                        return true;
                }