mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
chore: merge master
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Config\Connector;
|
||||
|
||||
use App\Entity\Domain;
|
||||
use Ovh\Api;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
readonly class OvhConnector implements ConnectorInterface
|
||||
@@ -138,7 +139,7 @@ readonly class OvhConnector implements ConnectorInterface
|
||||
|| !is_string($ovhSubsidiary) || empty($ovhSubsidiary)
|
||||
|| !is_string($pricingMode) || empty($pricingMode)
|
||||
) {
|
||||
throw new \Exception('Bad authData schema');
|
||||
throw new BadRequestHttpException('Bad authData schema');
|
||||
}
|
||||
|
||||
if (true !== $acceptConditions
|
||||
@@ -177,7 +178,7 @@ readonly class OvhConnector implements ConnectorInterface
|
||||
}
|
||||
|
||||
if (!$ok) {
|
||||
throw new \Exception('The credentials provided do not have enough permissions to purchase a domain name.');
|
||||
throw new BadRequestHttpException('The credentials provided do not have enough permissions to purchase a domain name.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ class DomainRefreshController extends AbstractController
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws HttpExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ExceptionInterface
|
||||
* @throws \Exception
|
||||
* @throws HttpExceptionInterface
|
||||
*/
|
||||
public function __invoke(string $ldhName, KernelInterface $kernel): ?Domain
|
||||
{
|
||||
|
||||
@@ -27,6 +27,15 @@ class DomainEntity
|
||||
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
|
||||
private array $roles = [];
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->updatedAt = new \DateTimeImmutable('now');
|
||||
}
|
||||
|
||||
public function getDomain(): ?Domain
|
||||
{
|
||||
return $this->domain;
|
||||
@@ -65,4 +74,23 @@ class DomainEntity
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(\DateTimeImmutable $updatedAt): static
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[ORM\PrePersist]
|
||||
#[ORM\PreUpdate]
|
||||
public function updateTimestamps(): void
|
||||
{
|
||||
$this->setUpdatedAt(new \DateTimeImmutable('now'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ use App\Repository\TldRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Exception\ORMException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;
|
||||
@@ -122,10 +124,10 @@ readonly class RDAPService
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws HttpExceptionInterface
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function registerDomain(string $fqdn): Domain
|
||||
{
|
||||
@@ -141,7 +143,7 @@ readonly class RDAPService
|
||||
$rdapServer = $this->rdapServerRepository->findOneBy(['tld' => $tld], ['updatedAt' => 'DESC']);
|
||||
|
||||
if (null === $rdapServer) {
|
||||
throw new \Exception('Unable to determine which RDAP server to contact');
|
||||
throw new NotFoundHttpException('Unable to determine which RDAP server to contact');
|
||||
}
|
||||
|
||||
/** @var ?Domain $domain */
|
||||
@@ -258,7 +260,8 @@ readonly class RDAPService
|
||||
$domain->addDomainEntity($domainEntity
|
||||
->setDomain($domain)
|
||||
->setEntity($entity)
|
||||
->setRoles($roles));
|
||||
->setRoles($roles))
|
||||
->updateTimestamps();
|
||||
|
||||
$this->em->persist($domainEntity);
|
||||
$this->em->flush();
|
||||
@@ -330,14 +333,11 @@ readonly class RDAPService
|
||||
return $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function getTld($domain): ?object
|
||||
{
|
||||
$lastDotPosition = strrpos($domain, '.');
|
||||
if (false === $lastDotPosition) {
|
||||
throw new \Exception('Domain must contain at least one dot');
|
||||
throw new BadRequestException('Domain must contain at least one dot');
|
||||
}
|
||||
$tld = strtolower(substr($domain, $lastDotPosition + 1));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user