From ab89e89b40106d8db9d1a5e6cced76bc4902e01f Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 8 Apr 2023 06:08:45 +0000 Subject: [PATCH 1/2] Issue 12977: Ensure to fetch quoted posts --- src/Protocol/ActivityPub/Receiver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 468af6c72..a52867616 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -630,7 +630,7 @@ class Receiver $object_data['object_activity'] = $activity; } - if (($type == 'as:Create') && $trust_source) { + if (($type == 'as:Create') && $trust_source && !in_array($completion, [self::COMPLETION_MANUAL, self::COMPLETION_ANNOUNCE])) { if (self::hasArrived($object_data['object_id'])) { Logger::info('The activity already arrived.', ['id' => $object_data['object_id']]); return true; @@ -641,6 +641,8 @@ class Receiver Logger::info('The activity is already added.', ['id' => $object_data['object_id']]); return true; } + } elseif (($type == 'as:Create') && $trust_source && !self::hasArrived($object_data['object_id'])) { + self::addArrivedId($object_data['object_id']); } $decouple = DI::config()->get('system', 'decoupled_receiver') && !in_array($completion, [self::COMPLETION_MANUAL, self::COMPLETION_ANNOUNCE]); From c07c34a6ec29de9ff9ca8eccc3e319615649a326 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 8 Apr 2023 06:35:12 +0000 Subject: [PATCH 2/2] Add the uri-id for the quoted post if it exists --- src/Protocol/ActivityPub/Processor.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 1963d7e05..86394bd91 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -840,6 +840,9 @@ class Processor if ($id) { $shared_item = Post::selectFirst(['uri-id'], ['id' => $id]); $item['quote-uri-id'] = $shared_item['uri-id']; + } elseif ($uri_id = ItemURI::getIdByURI($activity['quote-url'], false)) { + Logger::info('Quote was not fetched but the uri-id existed', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'uri-id' => $uri_id]); + $item['quote-uri-id'] = $uri_id; } else { Logger::info('Quote was not fetched', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url']]); }