]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Merge pull request #8660 from annando/item-insert
[friendica.git] / src / Protocol / Diaspora.php
index 7ab3d76da4432987d13b6f1fc4a72ff7ee9505e3..243550862be8e93010f310318a87856288619955 100644 (file)
@@ -261,12 +261,12 @@ class Diaspora
        public static function participantsForThread(array $item, array $contacts)
        {
                if (!in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) || in_array($item["verb"], [Activity::FOLLOW, Activity::TAG])) {
+                       Logger::info('Item is private or a participation request. It will not be relayed', ['guid' => $item['guid'], 'private' => $item['private'], 'verb' => $item['verb']]);
                        return $contacts;
                }
 
-               $items = Item::select(['author-id', 'author-link', 'parent-author-link'],
-                       ['parent' => $item['parent'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]],
-                       ['group_by' => ['author-id']]);
+               $items = Item::select(['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
+                       ['parent' => $item['parent'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
                while ($item = DBA::fetch($items)) {
                        $contact = DBA::selectFirst('contact', ['id', 'url', 'name', 'protocol', 'batch', 'network'],
                                ['id' => $item['author-id']]);
@@ -2284,6 +2284,10 @@ class Diaspora
                        return false;
                }
 
+               if (!$parent_item['origin']) {
+                       Logger::info('Not our origin. Participation is ignored', ['parent_guid' => $parent_guid, 'guid' => $guid, 'author' => $author]);
+               }
+
                if (!in_array($parent_item['private'], [Item::PUBLIC, Item::UNLISTED])) {
                        Logger::info('Item is not public, participation is ignored', ['parent_guid' => $parent_guid, 'guid' => $guid, 'author' => $author]);
                        return false;
@@ -2328,9 +2332,10 @@ class Diaspora
                Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]);
 
                // Send all existing comments and likes to the requesting server
-               $comments = Item::select(['id', 'uri-id', 'parent'], ['parent' => $parent_item['id']]);
+               $comments = Item::select(['id', 'uri-id', 'parent', 'verb'], ['parent' => $parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
                while ($comment = Item::fetch($comments)) {
-                       if ($comment['id'] == $comment['parent']) {
+                       if (in_array($comment["verb"], [Activity::FOLLOW, Activity::TAG])) {
+                               Logger::info('participation messages are not relayed', ['item' => $comment['id']]);
                                continue;
                        }
 
@@ -3134,7 +3139,9 @@ class Diaspora
                $json = json_encode(["iv" => $b_iv, "key" => $b_aes_key]);
 
                $encrypted_key_bundle = "";
-               openssl_public_encrypt($json, $encrypted_key_bundle, $pubkey);
+               if (!@openssl_public_encrypt($json, $encrypted_key_bundle, $pubkey)) {
+                       return false;
+               }
 
                $json_object = json_encode(
                        ["aes_key" => base64_encode($encrypted_key_bundle),