getUser()->getUserIdentifier(); $this->logger->info('User {username} wants to update the domain name {idnDomain}.', [ 'username' => $userId, 'idnDomain' => $idnDomain, ]); /** @var ?Domain $domain */ $domain = $this->domainRepository->findOneBy(['ldhName' => $idnDomain]); // If the domain name exists in the database, recently updated and not important, we return the stored Domain if (null !== $domain && !$domain->getDeleted() && ($domain->getUpdatedAt()->diff(new \DateTimeImmutable('now'))->days < 7) && !$this->RDAPService::isToBeWatchClosely($domain, $domain->getUpdatedAt()) ) { $this->logger->info('It is not necessary to update the information of the domain name {idnDomain} with the RDAP protocol.', [ 'idnDomain' => $idnDomain, ]); return $domain; } if (false === $kernel->isDebug()) { $limiter = $this->authenticatedApiLimiter->create($userId); if (false === $limiter->consume()->isAccepted()) { $this->logger->warning('User {username} was rate limited by the API.', [ 'username' => $this->getUser()->getUserIdentifier(), ]); throw new TooManyRequestsHttpException(); } } $updatedAt = null === $domain ? new \DateTimeImmutable('now') : $domain->getUpdatedAt(); $domain = $this->RDAPService->registerDomain($idnDomain); /** @var WatchList $watchList */ foreach ($domain->getWatchLists()->getIterator() as $watchList) { $this->bus->dispatch(new ProcessDomainTrigger($watchList->getToken(), $domain->getLdhName(), $updatedAt)); } return $domain; } }