[PLUGIN][ActivityPub][Model][Activity] Sometimes we don't have a local, move on with encapsulated

This commit is contained in:
Diogo Peralta Cordeiro 2022-03-23 13:17:35 +00:00
parent 8808195a80
commit 03f449035a
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0

View File

@ -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