From 03f449035a6a48acb1fc82a2a90148b6f5e47a20 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Wed, 23 Mar 2022 13:17:35 +0000 Subject: [PATCH] [PLUGIN][ActivityPub][Model][Activity] Sometimes we don't have a local, move on with encapsulated --- plugins/ActivityPub/Util/Model/Activity.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/ActivityPub/Util/Model/Activity.php b/plugins/ActivityPub/Util/Model/Activity.php index 23bcb770b2..12f465d19f 100644 --- a/plugins/ActivityPub/Util/Model/Activity.php +++ b/plugins/ActivityPub/Util/Model/Activity.php @@ -36,6 +36,7 @@ use ActivityPhp\Type; use ActivityPhp\Type\AbstractObject; use App\Core\DB\DB; use App\Core\Event; +use App\Core\Log; use App\Core\Router\Router; use App\Entity\Activity as GSActivity; use App\Util\Exception\ClientException; @@ -43,6 +44,7 @@ use App\Util\Exception\NoSuchActorException; use App\Util\Exception\NotFoundException; use App\Util\Exception\NotImplementedException; use DateTimeInterface; +use Exception; use InvalidArgumentException; use const JSON_UNESCAPED_SLASHES; use Plugin\ActivityPub\ActivityPub; @@ -92,7 +94,12 @@ class Activity extends Model $type_object = ActivityPub::getObjectByUri($type_object, try_online: true); } else { // Encapsulated, if we have it locally, prefer it // TODO: Test authority of activity over object - $type_object = ActivityPub::getObjectByUri($type_object->get('id'), try_online: false) ?? $type_object; + try { + $type_object = ActivityPub::getObjectByUri($type_object->get('id'), try_online: false); + } catch (Exception $e) { + // Use the encapsulated then + Log::debug('Failed to find a local activity, will continue with encapsulated.', [$e]); + } } if (($type_object instanceof Type\AbstractObject)) { // It's a new object apparently