Merge pull request #14357 from annando/callstack

Additional checks against fetch loops
pull/14365/head
Tobias Diekershoff 2024-08-15 07:03:45 +02:00 zatwierdzone przez GitHub
commit 89ac1c829b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 16 dodań i 6 usunięć

Wyświetl plik

@ -189,10 +189,11 @@ class Queue
*
* @param integer $id
* @param bool $fetch_parents
* @param array $parent
*
* @return bool
*/
public static function process(int $id, bool $fetch_parents = true): bool
public static function process(int $id, bool $fetch_parents = true, array $parent = []): bool
{
$entry = DBA::selectFirst('inbox-entry', [], ['id' => $id]);
if (empty($entry)) {
@ -226,6 +227,14 @@ class Queue
$activity['worker-id'] = $entry['wid'];
$activity['recursion-depth'] = 0;
if (!empty($parent['children'])) {
$activity['children'] = array_merge($activity['children'] ?? [], $parent['children']);
}
if (!empty($parent['callstack'])) {
$activity['callstack'] = array_merge($activity['callstack'] ?? [], $parent['callstack']);
}
if (empty($activity['thread-children-type'])) {
$activity['thread-children-type'] = $type;
}
@ -349,15 +358,16 @@ class Queue
* Process all activities that are children of a given post url
*
* @param string $uri
* @param array $parent
* @return int
*/
public static function processReplyByUri(string $uri): int
public static function processReplyByUri(string $uri, array $parent = []): int
{
$count = 0;
$entries = DBA::select('inbox-entry', ['id'], ["`in-reply-to-id` = ? AND `object-id` != ?", $uri, $uri]);
while ($entry = DBA::fetch($entries)) {
$count += 1;
self::process($entry['id'], false);
self::process($entry['id'], false, $parent);
}
DBA::close($entries);
return $count;

Wyświetl plik

@ -728,6 +728,9 @@ class Receiver
self::addArrivedId($object_data['object_id']);
}
$object_data['children'] = $activity['children'] ?? [];
$object_data['callstack'] = $activity['callstack'] ?? [];
$decouple = DI::config()->get('system', 'decoupled_receiver') && !in_array($completion, [self::COMPLETION_MANUAL, self::COMPLETION_ANNOUNCE]) && empty($object_data['directmessage']);
if ($decouple && ($trust_source || DI::config()->get('debug', 'ap_inbox_store_untrusted'))) {
@ -756,9 +759,6 @@ class Receiver
$object_data['recursion-depth'] = $activity['recursion-depth'];
}
$object_data['children'] = $activity['children'] ?? [];
$object_data['callstack'] = $activity['callstack'] ?? [];
if (!self::routeActivities($object_data, $type, $push, true, $uid)) {
self::storeUnhandledActivity(true, $type, $object_data, $activity, $body, $uid, $trust_source, $push, $signer);
Queue::remove($object_data);