[PLUGIN][ActivityPub][Util][Explorer] Simplify fetching Actor by URI

This commit is contained in:
2022-02-25 01:05:28 +00:00
parent 7c80277436
commit f5e92de62d
8 changed files with 110 additions and 138 deletions

View File

@@ -46,6 +46,7 @@ use DateTimeInterface;
use InvalidArgumentException;
use Plugin\ActivityPub\ActivityPub;
use Plugin\ActivityPub\Entity\ActivitypubActivity;
use Plugin\ActivityPub\Util\Explorer;
use Plugin\ActivityPub\Util\Model;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
@@ -84,7 +85,7 @@ class Activity extends Model
}
// Find Actor and Object
$actor = ActivityPub::getActorByUri($type_activity->get('actor'));
$actor = Explorer::getOneFromUri($type_activity->get('actor'));
$type_object = $type_activity->get('object');
if (\is_string($type_object)) { // Retrieve it
$type_object = ActivityPub::getObjectByUri($type_object, try_online: true);

View File

@@ -139,7 +139,7 @@ class Note extends Model
}
if (\is_null($actor_id)) {
$actor = ActivityPub::getActorByUri($type_note->get('attributedTo'));
$actor = Explorer::getOneFromUri($type_note->get('attributedTo'));
$actor_id = $actor->getId();
}
$map = [
@@ -190,8 +190,8 @@ class Note extends Model
continue;
}
try {
$actor = ActivityPub::getActorByUri($target);
$object_mentions_ids[$actor->getId()] = $target;
$actor = Explorer::getOneFromUri($target);
$attention_ids[$actor->getId()] = $target;
// If $to is a group and note is unlisted, set note's scope as Group
if ($actor->isGroup() && $map['scope'] === 'unlisted') {
$map['scope'] = VisibilityScope::GROUP;
@@ -211,8 +211,8 @@ class Note extends Model
continue;
}
try {
$actor = ActivityPub::getActorByUri($target);
$object_mentions_ids[$actor->getId()] = $target;
$actor = Explorer::getOneFromUri($target);
$attention_ids[$actor->getId()] = $target;
} catch (Exception $e) {
Log::debug('ActivityPub->Model->Note->fromJson->getActorByUri', [$e]);
}