]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Merge pull request #10090 from nupplaphil/feat/install_testrewrite
[friendica.git] / src / Protocol / Diaspora.php
index 7ba385b6e9b0e2e61fe6f4e466e23d256b143784..c33896c517f8ca86c00b78e1a99a14fd3d0c91e2 100644 (file)
@@ -35,6 +35,7 @@ use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Conversation;
 use Friendica\Model\FContact;
+use Friendica\Model\GServer;
 use Friendica\Model\Item;
 use Friendica\Model\ItemURI;
 use Friendica\Model\Mail;
@@ -1498,6 +1499,10 @@ class Diaspora
                        return false;
                }
 
+               if (!empty($contact['gsid'])) {
+                       GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
+               }
+
                $message_id = self::messageExists($importer["uid"], $guid);
                if ($message_id) {
                        return true;
@@ -1682,6 +1687,10 @@ class Diaspora
                        return false;
                }
 
+               if (!empty($contact['gsid'])) {
+                       GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
+               }
+
                $conversation = DBA::selectFirst('conv', [], ['uid' => $importer["uid"], 'guid' => $guid]);
                if (!DBA::isResult($conversation)) {
                        $r = q(
@@ -1741,6 +1750,10 @@ class Diaspora
                        return false;
                }
 
+               if (!empty($contact['gsid'])) {
+                       GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
+               }
+
                $message_id = self::messageExists($importer["uid"], $guid);
                if ($message_id) {
                        return true;
@@ -1851,6 +1864,10 @@ class Diaspora
                        return false;
                }
 
+               if (!empty($contact['gsid'])) {
+                       GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
+               }
+
                $conversation = null;
 
                $condition = ['uid' => $importer["uid"], 'guid' => $conversation_guid];
@@ -1911,6 +1928,10 @@ class Diaspora
                        return false;
                }
 
+               if (!empty($contact['gsid'])) {
+                       GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
+               }
+
                if (self::messageExists($importer["uid"], $guid)) {
                        return true;
                }
@@ -2407,6 +2428,10 @@ class Diaspora
                        return false;
                }
 
+               if (!empty($contact['gsid'])) {
+                       GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
+               }
+
                $message_id = self::messageExists($importer["uid"], $guid);
                if ($message_id) {
                        return true;
@@ -2679,6 +2704,10 @@ class Diaspora
                        return false;
                }
 
+               if (!empty($contact['gsid'])) {
+                       GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
+               }
+
                $message_id = self::messageExists($importer["uid"], $guid);
                if ($message_id) {
                        return true;
@@ -3099,17 +3128,7 @@ class Diaspora
                        return;
                }
 
-               // Fetch some user id to have a valid handle to transmit the participation.
-               // In fact it doesn't matter which user sends this - but it is needed by the protocol.
-               // If the item belongs to a user, we take this user id.
-               if ($item['uid'] == 0) {
-                       $condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false];
-                       $first_user = DBA::selectFirst('user', ['uid'], $condition);
-                       $owner = User::getOwnerDataById($first_user['uid']);
-               } else {
-                       $owner = User::getOwnerDataById($item['uid']);
-               }
-
+               $owner = User::getOwnerDataById($item['uid']);
                $author = self::myHandle($owner);
 
                $message = ["author" => $author,
@@ -3599,7 +3618,7 @@ class Diaspora
                        return $result;
                }
 
-               $toplevel_item = Post::selectFirst(['guid', 'author-id', 'author-link'], ['id' => $item['parent'], 'parent' => $item['parent']]);
+               $toplevel_item = Post::selectFirst(['guid', 'author-id', 'author-link', 'gravity'], ['id' => $item['parent'], 'parent' => $item['parent']]);
                if (!DBA::isResult($toplevel_item)) {
                        Logger::error('Missing parent conversation item', ['parent' => $item['parent']]);
                        return false;
@@ -3607,7 +3626,7 @@ class Diaspora
 
                $thread_parent_item = $toplevel_item;
                if ($item['thr-parent'] != $item['parent-uri']) {
-                       $thread_parent_item = Post::selectFirst(['guid', 'author-id', 'author-link'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
+                       $thread_parent_item = Post::selectFirst(['guid', 'author-id', 'author-link', 'gravity'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
                }
 
                $body = $item["body"];
@@ -3618,6 +3637,7 @@ class Diaspora
                // - Implicit mentions are enabled
                if (
                        $item['author-id'] != $thread_parent_item['author-id']
+                       && ($thread_parent_item['gravity'] != GRAVITY_PARENT)
                        && (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions'))
                        && !DI::config()->get('system', 'disable_implicit_mentions')
                ) {