New option to disable the fetching of parents

This commit is contained in:
Michael 2022-08-04 19:32:36 +00:00
parent 196a1de7f2
commit 06f7244280
4 changed files with 34 additions and 8 deletions

View 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 [];
}

View 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)) {

View 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]);

View 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',