mirror of
https://github.com/friendica/friendica
synced 2024-11-10 03:02:54 +00:00
Merge pull request #14357 from annando/callstack
Additional checks against fetch loops
This commit is contained in:
commit
89ac1c829b
2 changed files with 16 additions and 6 deletions
|
@ -189,10 +189,11 @@ class Queue
|
||||||
*
|
*
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @param bool $fetch_parents
|
* @param bool $fetch_parents
|
||||||
|
* @param array $parent
|
||||||
*
|
*
|
||||||
* @return bool
|
* @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]);
|
$entry = DBA::selectFirst('inbox-entry', [], ['id' => $id]);
|
||||||
if (empty($entry)) {
|
if (empty($entry)) {
|
||||||
|
@ -226,6 +227,14 @@ class Queue
|
||||||
$activity['worker-id'] = $entry['wid'];
|
$activity['worker-id'] = $entry['wid'];
|
||||||
$activity['recursion-depth'] = 0;
|
$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'])) {
|
if (empty($activity['thread-children-type'])) {
|
||||||
$activity['thread-children-type'] = $type;
|
$activity['thread-children-type'] = $type;
|
||||||
}
|
}
|
||||||
|
@ -349,15 +358,16 @@ class Queue
|
||||||
* Process all activities that are children of a given post url
|
* Process all activities that are children of a given post url
|
||||||
*
|
*
|
||||||
* @param string $uri
|
* @param string $uri
|
||||||
|
* @param array $parent
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function processReplyByUri(string $uri): int
|
public static function processReplyByUri(string $uri, array $parent = []): int
|
||||||
{
|
{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$entries = DBA::select('inbox-entry', ['id'], ["`in-reply-to-id` = ? AND `object-id` != ?", $uri, $uri]);
|
$entries = DBA::select('inbox-entry', ['id'], ["`in-reply-to-id` = ? AND `object-id` != ?", $uri, $uri]);
|
||||||
while ($entry = DBA::fetch($entries)) {
|
while ($entry = DBA::fetch($entries)) {
|
||||||
$count += 1;
|
$count += 1;
|
||||||
self::process($entry['id'], false);
|
self::process($entry['id'], false, $parent);
|
||||||
}
|
}
|
||||||
DBA::close($entries);
|
DBA::close($entries);
|
||||||
return $count;
|
return $count;
|
||||||
|
|
|
@ -728,6 +728,9 @@ class Receiver
|
||||||
self::addArrivedId($object_data['object_id']);
|
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']);
|
$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'))) {
|
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['recursion-depth'] = $activity['recursion-depth'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$object_data['children'] = $activity['children'] ?? [];
|
|
||||||
$object_data['callstack'] = $activity['callstack'] ?? [];
|
|
||||||
|
|
||||||
if (!self::routeActivities($object_data, $type, $push, true, $uid)) {
|
if (!self::routeActivities($object_data, $type, $push, true, $uid)) {
|
||||||
self::storeUnhandledActivity(true, $type, $object_data, $activity, $body, $uid, $trust_source, $push, $signer);
|
self::storeUnhandledActivity(true, $type, $object_data, $activity, $body, $uid, $trust_source, $push, $signer);
|
||||||
Queue::remove($object_data);
|
Queue::remove($object_data);
|
||||||
|
|
Loading…
Reference in a new issue