From f6d11e84016de4d1a90b0c9346b6cb421ab973df Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 30 Jul 2022 04:43:18 +0000 Subject: [PATCH 1/2] Issue 11800: Remove entry from queue in any case. --- src/Protocol/ActivityPub/Processor.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 2438c68c6..5cb847442 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -215,14 +215,13 @@ class Processor $item['edited'] = DateTimeFormat::utc($activity['updated']); $item = self::processContent($activity, $item); - - self::storeAttachments($activity, $item); - self::storeQuestion($activity, $item); - if (empty($item)) { return; } + self::storeAttachments($activity, $item); + self::storeQuestion($activity, $item); + Post\History::add($item['uri-id'], $item); Item::update($item, ['uri' => $activity['id']]); @@ -919,7 +918,7 @@ class Processor continue; } - if (!($item['isForum'] ?? false) && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT) && !Contact::isSharingByURL($activity['author'], $receiver)) { + if (!($item['isForum'] ?? false) && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT) && !Contact::isSharingByURL($activity['author'] ?? '', $receiver)) { if ($item['post-reason'] == Item::PR_BCC) { Logger::info('Top level post via BCC from a non sharer, ignoring', ['uid' => $receiver, 'contact' => $item['contact-id']]); continue; @@ -972,9 +971,6 @@ class Processor $success = true; } else { Logger::notice('Item insertion aborted', ['uri' => $item['uri'], 'uid' => $item['uid']]); - if (Item::isTooOld($item) || !Item::isValid($item)) { - Queue::remove($activity); - } } if ($item['uid'] == 0) { @@ -982,12 +978,10 @@ class Processor } } - if ($success) { - Queue::remove($activity); + Queue::remove($activity); - if (Queue::hasChildren($item['uri'])) { - Worker::add(PRIORITY_HIGH, 'ProcessReplyByUri', $item['uri']); - } + if ($success && Queue::hasChildren($item['uri'])) { + Worker::add(PRIORITY_HIGH, 'ProcessReplyByUri', $item['uri']); } // Store send a follow request for every reshare - but only when the item had been stored From 8b4bf890f82c28439e6cddb4502ffa16f19ac814 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 30 Jul 2022 05:30:08 +0000 Subject: [PATCH 2/2] Issue 11798: Handling of empty author --- src/Protocol/ActivityPub/Processor.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 5cb847442..e3e2e295a 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -299,6 +299,11 @@ class Processor $conversation = []; } + if (empty($activity['author']) && empty($activity['actor'])) { + Logger::notice('Missing author and actor. We quit here.', ['activity' => $activity]); + return []; + } + if (empty($activity['directmessage']) && ($activity['id'] != $activity['reply-to-id']) && !Post::exists(['uri' => $activity['reply-to-id']])) { $recursion_depth = $activity['recursion-depth'] ?? 0; Logger::notice('Parent not found. Try to refetch it.', ['parent' => $activity['reply-to-id'], 'recursion-depth' => $recursion_depth]); @@ -918,7 +923,7 @@ class Processor continue; } - if (!($item['isForum'] ?? false) && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT) && !Contact::isSharingByURL($activity['author'] ?? '', $receiver)) { + if (!($item['isForum'] ?? false) && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT) && !Contact::isSharingByURL($activity['author'], $receiver)) { if ($item['post-reason'] == Item::PR_BCC) { Logger::info('Top level post via BCC from a non sharer, ignoring', ['uid' => $receiver, 'contact' => $item['contact-id']]); continue;