diff --git a/src/Model/Item.php b/src/Model/Item.php index 7eb36d85e..3bacd9cc6 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -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 []; } diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index d58628ff2..7270f7fc4 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -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)) { diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 36d1a76b7..843d50ca0 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -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]); diff --git a/static/defaults.config.php b/static/defaults.config.php index 44c80b7b0..7e34ae66e 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -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',