commit
54dc95ec81
|
@ -4126,6 +4126,10 @@ class Item
|
|||
return $item_id;
|
||||
}
|
||||
|
||||
if (ActivityPub\Processor::alreadyKnown($uri, '')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$hookData = [
|
||||
'uri' => $uri,
|
||||
'uid' => $uid,
|
||||
|
|
|
@ -1702,7 +1702,9 @@ class Processor
|
|||
}
|
||||
Logger::debug('Fetch announced activity', ['type' => $type, 'id' => $object_id, 'actor' => $relay_actor, 'signer' => $signer]);
|
||||
|
||||
return self::fetchMissingActivity($object_id, $child, $relay_actor, $completion, $uid);
|
||||
if (!self::alreadyKnown($object_id, $child['id'] ?? '')) {
|
||||
return self::fetchMissingActivity($object_id, $child, $relay_actor, $completion, $uid);
|
||||
}
|
||||
}
|
||||
$activity = $object;
|
||||
$ldactivity = $ldobject;
|
||||
|
@ -1768,14 +1770,7 @@ class Processor
|
|||
if (is_array($reply)) {
|
||||
$ldobject = JsonLD::compact($reply);
|
||||
$id = JsonLD::fetchElement($ldobject, '@id');
|
||||
if ($id == $child['id']) {
|
||||
Logger::debug('Incluced activity is currently processed', ['replies' => $url, 'id' => $id]);
|
||||
continue;
|
||||
} elseif (Item::searchByLink($id)) {
|
||||
Logger::debug('Incluced activity already exists', ['replies' => $url, 'id' => $id]);
|
||||
continue;
|
||||
} elseif (Queue::exists($id, 'as:Create')) {
|
||||
Logger::debug('Incluced activity is already queued', ['replies' => $url, 'id' => $id]);
|
||||
if (Processor::alreadyKnown($id, $child['id'] ?? '')) {
|
||||
continue;
|
||||
}
|
||||
if (parse_url($id, PHP_URL_HOST) == parse_url($url, PHP_URL_HOST)) {
|
||||
|
@ -1787,14 +1782,7 @@ class Processor
|
|||
} elseif (is_string($reply)) {
|
||||
$id = $reply;
|
||||
}
|
||||
if ($id == $child['id']) {
|
||||
Logger::debug('Activity is currently processed', ['replies' => $url, 'id' => $id]);
|
||||
} elseif (Item::searchByLink($id)) {
|
||||
Logger::debug('Activity already exists', ['replies' => $url, 'id' => $id]);
|
||||
} elseif (Queue::exists($id, 'as:Create')) {
|
||||
Logger::debug('Activity is already queued', ['replies' => $url, 'id' => $id]);
|
||||
} else {
|
||||
Logger::debug('Missing Activity will be fetched and processed', ['replies' => $url, 'id' => $id]);
|
||||
if (!self::alreadyKnown($id, $child['id'] ?? '')) {
|
||||
self::fetchMissingActivity($id, $child, '', Receiver::COMPLETION_REPLIES);
|
||||
++$fetched;
|
||||
}
|
||||
|
@ -1802,6 +1790,22 @@ class Processor
|
|||
Logger::notice('Fetch replies - done', ['fetched' => $fetched, 'total' => count($replies), 'replies' => $url]);
|
||||
}
|
||||
|
||||
public static function alreadyKnown(string $id, string $child): bool
|
||||
{
|
||||
if ($id == $child) {
|
||||
Logger::debug('Activity is currently processed', ['id' => $id, 'child' => $child]);
|
||||
return true;
|
||||
} elseif (Item::searchByLink($id)) {
|
||||
Logger::debug('Activity already exists', ['id' => $id, 'child' => $child]);
|
||||
return true;
|
||||
} elseif (Queue::exists($id, 'as:Create')) {
|
||||
Logger::debug('Activity is already queued', ['id' => $id, 'child' => $child]);
|
||||
return true;
|
||||
}
|
||||
Logger::debug('Activity is unknown', ['id' => $id, 'child' => $child]);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function refetchObjectOnHostDifference(array $object, string $url): array
|
||||
{
|
||||
$ldobject = JsonLD::compact($object);
|
||||
|
|
|
@ -828,7 +828,7 @@ class Receiver
|
|||
|
||||
case 'as:Announce':
|
||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||
if (!Item::searchByLink($object_data['object_id'], $uid)) {
|
||||
if (!Processor::alreadyKnown($object_data['object_id'], '')) {
|
||||
if (ActivityPub\Processor::fetchMissingActivity($object_data['object_id'], [], $object_data['actor'], self::COMPLETION_ANNOUNCE, $uid)) {
|
||||
Logger::debug('Created announced id', ['uid' => $uid, 'id' => $object_data['object_id']]);
|
||||
Queue::remove($object_data);
|
||||
|
|
|
@ -41,6 +41,10 @@ class FetchMissingActivity
|
|||
public static function execute(string $url, array $child = [], string $relay_actor = '', int $completion = Receiver::COMPLETION_MANUAL)
|
||||
{
|
||||
Logger::info('Start fetching missing activity', ['url' => $url]);
|
||||
if (ActivityPub\Processor::alreadyKnown($url, $child['id'] ?? '')) {
|
||||
Logger::info('Activity is already known.', ['url' => $url]);
|
||||
return;
|
||||
}
|
||||
$result = ActivityPub\Processor::fetchMissingActivity($url, $child, $relay_actor, $completion);
|
||||
if ($result) {
|
||||
Logger::info('Successfully fetched missing activity', ['url' => $url]);
|
||||
|
|
Loading…
Reference in New Issue