Skip to content

Commit

Permalink
Use activityPubManager variable consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
melroy89 committed Dec 17, 2024
1 parent 4f4802e commit c9d3aaf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/MessageHandler/ActivityPub/Inbox/ActivityHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(
private readonly SignatureValidator $signatureValidator,
private readonly SettingsManager $settingsManager,
private readonly MessageBusInterface $bus,
private readonly ActivityPubManager $manager,
private readonly ActivityPubManager $activityPubManager,
private readonly ApHttpClient $apHttpClient,
private readonly InstanceRepository $instanceRepository,
private readonly RemoteInstanceManager $remoteInstanceManager,
Expand Down Expand Up @@ -119,15 +119,15 @@ public function doWork(MessageInterface $message): void

try {
if (isset($payload['actor']) || isset($payload['attributedTo'])) {
if (!$this->verifyInstanceDomain($payload['actor'] ?? $this->manager->getSingleActorFromAttributedTo($payload['attributedTo']))) {
if (!$this->verifyInstanceDomain($payload['actor'] ?? $this->activityPubManager->getSingleActorFromAttributedTo($payload['attributedTo']))) {
return;
}
$user = $this->manager->findActorOrCreate($payload['actor'] ?? $this->manager->getSingleActorFromAttributedTo($payload['attributedTo']));
$user = $this->activityPubManager->findActorOrCreate($payload['actor'] ?? $this->activityPubManager->getSingleActorFromAttributedTo($payload['attributedTo']));
} else {
if (!$this->verifyInstanceDomain($payload['id'])) {
return;
}
$user = $this->manager->findActorOrCreate($payload['id']);
$user = $this->activityPubManager->findActorOrCreate($payload['id']);
}
} catch (\Exception $e) {
$this->logger->error('[ActivityHandler::doWork] Payload: '.json_encode($payload));
Expand Down Expand Up @@ -157,7 +157,7 @@ private function handle(?array $payload)
if ('Announce' === $payload['type']) {
// we check for an array here, because boosts are announces with an url (string) as the object
if (\is_array($payload['object'])) {
$actorObject = $this->manager->findActorOrCreate($payload['actor']);
$actorObject = $this->activityPubManager->findActorOrCreate($payload['actor']);
if ($actorObject instanceof Magazine && $actorObject->lastOriginUpdate < (new \DateTime())->modify('-3 hours')) {
if (isset($payload['object']['type']) && 'Create' === $payload['object']['type']) {
$actorObject->lastOriginUpdate = new \DateTime();
Expand All @@ -169,7 +169,7 @@ private function handle(?array $payload)
$payload = $payload['object'];
$actor = $payload['actor'] ?? $payload['attributedTo'] ?? null;
if ($actor) {
$user = $this->manager->findActorOrCreate($actor);
$user = $this->activityPubManager->findActorOrCreate($actor);
if ($user instanceof User && null === $user->apId) {
// don't do anything if we get an announce activity for something a local user did (unless it's a boost, see comment above)
$this->logger->warning('[ActivityHandler::handle] Ignoring this message because it announces an activity from a local user');
Expand Down
4 changes: 2 additions & 2 deletions src/MessageHandler/ActivityPub/Outbox/DeliverHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DeliverHandler extends MbinMessageHandler
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly ApHttpClient $client,
private readonly ActivityPubManager $manager,
private readonly ActivityPubManager $activityPubManager,
private readonly SettingsManager $settingsManager,
private readonly LoggerInterface $logger,
private readonly InstanceRepository $instanceRepository,
Expand Down Expand Up @@ -120,7 +120,7 @@ public function doWork(MessageInterface $message): void
$url = $message->payload['actor'];
}
$this->logger->debug("Getting Actor for url: $url");
$actor = $this->manager->findActorOrCreate($url);
$actor = $this->activityPubManager->findActorOrCreate($url);

if (!$actor) {
$this->logger->debug('got no actor :(');
Expand Down
4 changes: 2 additions & 2 deletions src/MessageHandler/ActivityPub/UpdateActorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class UpdateActorHandler extends MbinMessageHandler
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly ActivityPubManager $manager,
private readonly ActivityPubManager $activityPubManager,
private readonly ApHttpClient $apHttpClient,
private readonly LockFactory $lockFactory,
private readonly UserRepository $userRepository,
Expand Down Expand Up @@ -61,7 +61,7 @@ public function doWork(MessageInterface $message): void
$this->apHttpClient->invalidateActorObjectCache($actorUrl);
}
if ($message->force || $actor->apFetchedAt < (new \DateTime())->modify('-1 hour')) {
$this->manager->updateActor($actorUrl);
$this->activityPubManager->updateActor($actorUrl);
} else {
$this->logger->debug('not updating actor {url}: last updated is recent: {fetched}', [
'url' => $actorUrl,
Expand Down

0 comments on commit c9d3aaf

Please sign in to comment.