commit
54dc95ec81
|
@ -4126,6 +4126,10 @@ class Item
|
||||||
return $item_id;
|
return $item_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ActivityPub\Processor::alreadyKnown($uri, '')) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$hookData = [
|
$hookData = [
|
||||||
'uri' => $uri,
|
'uri' => $uri,
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
|
|
|
@ -1702,8 +1702,10 @@ class Processor
|
||||||
}
|
}
|
||||||
Logger::debug('Fetch announced activity', ['type' => $type, 'id' => $object_id, 'actor' => $relay_actor, 'signer' => $signer]);
|
Logger::debug('Fetch announced activity', ['type' => $type, 'id' => $object_id, 'actor' => $relay_actor, 'signer' => $signer]);
|
||||||
|
|
||||||
|
if (!self::alreadyKnown($object_id, $child['id'] ?? '')) {
|
||||||
return self::fetchMissingActivity($object_id, $child, $relay_actor, $completion, $uid);
|
return self::fetchMissingActivity($object_id, $child, $relay_actor, $completion, $uid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$activity = $object;
|
$activity = $object;
|
||||||
$ldactivity = $ldobject;
|
$ldactivity = $ldobject;
|
||||||
} elseif (!empty($object['id'])) {
|
} elseif (!empty($object['id'])) {
|
||||||
|
@ -1768,14 +1770,7 @@ class Processor
|
||||||
if (is_array($reply)) {
|
if (is_array($reply)) {
|
||||||
$ldobject = JsonLD::compact($reply);
|
$ldobject = JsonLD::compact($reply);
|
||||||
$id = JsonLD::fetchElement($ldobject, '@id');
|
$id = JsonLD::fetchElement($ldobject, '@id');
|
||||||
if ($id == $child['id']) {
|
if (Processor::alreadyKnown($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]);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (parse_url($id, PHP_URL_HOST) == parse_url($url, PHP_URL_HOST)) {
|
if (parse_url($id, PHP_URL_HOST) == parse_url($url, PHP_URL_HOST)) {
|
||||||
|
@ -1787,14 +1782,7 @@ class Processor
|
||||||
} elseif (is_string($reply)) {
|
} elseif (is_string($reply)) {
|
||||||
$id = $reply;
|
$id = $reply;
|
||||||
}
|
}
|
||||||
if ($id == $child['id']) {
|
if (!self::alreadyKnown($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]);
|
|
||||||
self::fetchMissingActivity($id, $child, '', Receiver::COMPLETION_REPLIES);
|
self::fetchMissingActivity($id, $child, '', Receiver::COMPLETION_REPLIES);
|
||||||
++$fetched;
|
++$fetched;
|
||||||
}
|
}
|
||||||
|
@ -1802,6 +1790,22 @@ class Processor
|
||||||
Logger::notice('Fetch replies - done', ['fetched' => $fetched, 'total' => count($replies), 'replies' => $url]);
|
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
|
private static function refetchObjectOnHostDifference(array $object, string $url): array
|
||||||
{
|
{
|
||||||
$ldobject = JsonLD::compact($object);
|
$ldobject = JsonLD::compact($object);
|
||||||
|
|
|
@ -828,7 +828,7 @@ class Receiver
|
||||||
|
|
||||||
case 'as:Announce':
|
case 'as:Announce':
|
||||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
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)) {
|
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']]);
|
Logger::debug('Created announced id', ['uid' => $uid, 'id' => $object_data['object_id']]);
|
||||||
Queue::remove($object_data);
|
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)
|
public static function execute(string $url, array $child = [], string $relay_actor = '', int $completion = Receiver::COMPLETION_MANUAL)
|
||||||
{
|
{
|
||||||
Logger::info('Start fetching missing activity', ['url' => $url]);
|
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);
|
$result = ActivityPub\Processor::fetchMissingActivity($url, $child, $relay_actor, $completion);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
Logger::info('Successfully fetched missing activity', ['url' => $url]);
|
Logger::info('Successfully fetched missing activity', ['url' => $url]);
|
||||||
|
|
Loading…
Reference in New Issue