Skip to content

Commit

Permalink
Push isBannedInstance check down, after the single findOneBy call
Browse files Browse the repository at this point in the history
  • Loading branch information
melroy89 committed Dec 17, 2024
1 parent 918af27 commit 4f4802e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Service/ActivityPubManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ public function findActorOrCreate(?string $actorUrlOrHandle): User|Magazine|null
$actorUrl = $this->webfinger($actorUrl)->getProfileId();
}

// Check if the instance is banned
if ($this->settingsManager->isBannedInstance($actorUrl)) {
return null;
}

if (\in_array(
parse_url($actorUrl, PHP_URL_HOST),
[$this->settingsManager->get('KBIN_DOMAIN'), 'localhost', '127.0.0.1']
Expand All @@ -177,6 +172,11 @@ public function findActorOrCreate(?string $actorUrlOrHandle): User|Magazine|null
return $this->userRepository->findOneBy(['username' => $name]);
}

// Check if the instance is banned
if ($this->settingsManager->isBannedInstance($actorUrl)) {
return null;
}

$user = $this->userRepository->findOneBy(['apProfileId' => $actorUrl]);
if ($user instanceof User) {
$this->logger->debug('[ActivityPubManager::findActorOrCreate] Found remote user for url: "{url}" in db', ['url' => $actorUrl]);
Expand All @@ -186,6 +186,7 @@ public function findActorOrCreate(?string $actorUrlOrHandle): User|Magazine|null

return $user;
}

$magazine = $this->magazineRepository->findOneBy(['apProfileId' => $actorUrl]);
if ($magazine instanceof Magazine) {
$this->logger->debug('[ActivityPubManager::findActorOrCreate] Found remote user for url: "{url}" in db', ['url' => $actorUrl]);
Expand Down

0 comments on commit 4f4802e

Please sign in to comment.