diff --git a/src/Controller/WatchListController.php b/src/Controller/WatchListController.php index 4629f37..5dbe8ad 100644 --- a/src/Controller/WatchListController.php +++ b/src/Controller/WatchListController.php @@ -39,6 +39,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\RateLimiter\RateLimiterFactory; @@ -408,7 +409,18 @@ class WatchListController extends AbstractController $domain = $this->domainRepository->findOneBy(['ldhName' => $ldhName]); if (null === $domain) { - $domain = $this->RDAPService->registerDomain($ldhName); + try { + $domain = $this->RDAPService->registerDomain($ldhName); + } catch (NotFoundHttpException) { + $domain = (new Domain()) + ->setLdhName($ldhName) + ->setTld($this->RDAPService->getTld($ldhName)) + ->setDelegationSigned(false) + ->setDeleted(true); + + $this->em->persist($domain); + $this->em->flush(); + } if (false === $this->kernel->isDebug() && true === $this->getParameter('limited_features')) { $limiter = $this->rdapRequestsLimiter->create($this->getUser()->getUserIdentifier()); diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index 64c80d3..dd92563 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -170,7 +170,7 @@ readonly class RDAPService return $domain; } - private function getTld(string $domain): Tld + public function getTld(string $domain): Tld { if (!str_contains($domain, '.')) { $tldEntity = $this->tldRepository->findOneBy(['tld' => '.']);