]> git.mxchange.org Git - friendica.git/commitdiff
New option to disable the fetching of parents
authorMichael <heluecht@pirati.ca>
Thu, 4 Aug 2022 19:32:36 +0000 (19:32 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 4 Aug 2022 19:32:36 +0000 (19:32 +0000)
src/Model/Item.php
src/Protocol/ActivityPub/Processor.php
src/Worker/Notifier.php
static/defaults.config.php

index 7eb36d85e025f2aaae996af6db3a6d676cb08f96..3bacd9cc6abf002e873b9a13f664383de5ca0b3d 100644 (file)
@@ -706,7 +706,7 @@ class Item
                }
 
                if (!DBA::isResult($parent)) {
-                       Logger::notice('item parent was not found - ignoring item', ['thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
+                       Logger::notice('item parent was not found - ignoring item', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid'], 'callstack' => System::callstack(20)]);
                        return [];
                }
 
index d58628ff2a190336aa8183a85aea2a364cba6000..7270f7fc4b8e72bef85b388be2bdc7a899bba45f 100644 (file)
@@ -308,6 +308,10 @@ class Processor
                        return [];
                }
 
+               if (!DI::config()->get('system', 'fetch_parents')) {
+                       $fetch_parents = false;
+               }
+
                if ($fetch_parents && empty($activity['directmessage']) && ($activity['id'] != $activity['reply-to-id']) && !Post::exists(['uri' => $activity['reply-to-id']])) {
                        $result = self::fetchParent($activity);
                        if (!empty($result)) {
index 36d1a76b73de6ed8bc9adcbd4553cfa9ff65447d..843d50ca059cded968b1b420c854c584dd2a2396 100644 (file)
@@ -505,9 +505,17 @@ class Notifier
                foreach ($contacts as $contact) {
                        // Direct delivery of local contacts
                        if (!in_array($cmd, [Delivery::RELOCATION, Delivery::SUGGESTION, Delivery::DELETION, Delivery::MAIL]) && $target_uid = User::getIdForURL($contact['url'])) {
-                               Logger::info('Direct delivery', ['uri-id' => $target_item['uri-id'], 'target' => $target_uid]);
-                               $fields = ['protocol' => Conversation::PARCEL_LOCAL_DFRN, 'direction' => Conversation::PUSH, 'post-reason' => Item::PR_DIRECT];
-                               Item::storeForUserByUriId($target_item['uri-id'], $target_uid, $fields, $target_item['uid']);
+                               if ($target_item['origin'] || ($target_item['network'] != Protocol::ACTIVITYPUB)) {
+                                       if ($target_uid != $target_item['uid']) {
+                                               $fields = ['protocol' => Conversation::PARCEL_LOCAL_DFRN, 'direction' => Conversation::PUSH, 'post-reason' => Item::PR_DIRECT];
+                                               Item::storeForUserByUriId($target_item['uri-id'], $target_uid, $fields, $target_item['uid']);
+                                               Logger::info('Delivered locally', ['cmd' => $cmd, 'id' => $target_item['id'], 'target' => $target_uid]);
+                                       } else {
+                                               Logger::info('No need to deliver to myself', ['uid' => $target_uid, 'guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'uri' => $target_item['uri']]);
+                                       }
+                               } else {
+                                       Logger::info('Remote item does not need to be delivered locally', ['guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'uri' => $target_item['uri']]);
+                               }
                                continue;
                        }
 
@@ -775,12 +783,22 @@ class Notifier
 
                        if ((count($receivers) == 1) && Network::isLocalLink($inbox)) {
                                $contact = Contact::getById($receivers[0], ['url']);
-                               if ($target_uid = User::getIdForURL($contact['url'])) {
-                                       $fields = ['protocol' => Conversation::PARCEL_LOCAL_DFRN, 'direction' => Conversation::PUSH, 'post-reason' => Item::PR_BCC];
-                                       Item::storeForUserByUriId($target_item['uri-id'], $target_uid, $fields, $target_item['uid']);
-                                       Logger::info('Delivered locally', ['cmd' => $cmd, 'id' => $target_item['id'], 'inbox' => $inbox]);
+                               if (!in_array($cmd, [Delivery::RELOCATION, Delivery::SUGGESTION, Delivery::DELETION, Delivery::MAIL]) && ($target_uid = User::getIdForURL($contact['url']))) {
+                                       if ($target_item['origin'] || ($target_item['network'] != Protocol::ACTIVITYPUB)) {
+                                               if ($target_uid != $target_item['uid']) {
+                                                       $fields = ['protocol' => Conversation::PARCEL_LOCAL_DFRN, 'direction' => Conversation::PUSH, 'post-reason' => Item::PR_BCC];
+                                                       Item::storeForUserByUriId($target_item['uri-id'], $target_uid, $fields, $target_item['uid']);
+                                                       Logger::info('Delivered locally', ['cmd' => $cmd, 'id' => $target_item['id'], 'inbox' => $inbox]);
+                                               } else {
+                                                       Logger::info('No need to deliver to myself', ['uid' => $target_uid, 'guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'uri' => $target_item['uri']]);
+                                               }
+                                       } else {
+                                               Logger::info('Remote item does not need to be delivered locally', ['guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'uri' => $target_item['uri']]);
+                                       }
                                        continue;
                                }
+                       } elseif ((count($receivers) >= 1) && Network::isLocalLink($inbox)) {
+                               Logger::info('Is this a thing?', ['guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'uri' => $target_item['uri']]);
                        }
 
                        Logger::info('Delivery via ActivityPub', ['cmd' => $cmd, 'id' => $target_item['id'], 'inbox' => $inbox]);
index 44c80b7b0c9a9f595220a10a0a46f71232e469cb..7e34ae66e7749ffde886467f2fec30aad539379c 100644 (file)
@@ -172,6 +172,10 @@ return [
                // Whether to use database, Memcache, Memcached or Redis as a distributed cache.
                'distributed_cache_driver' => 'database',
 
+               // fetch_parents (Boolean)
+               // Fetch missing parent posts
+               'fetch_parents' => true,
+
                // config_adapter (jit|preload)
                // Allow to switch the configuration adapter to improve performances at the cost of memory consumption.
                'config_adapter' => 'jit',