mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
Merge pull request #12 from vinceh121/master
feat: RDAP servers update command
This commit is contained in:
40
src/Command/UpdateRdapServersCommand.php
Normal file
40
src/Command/UpdateRdapServersCommand.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Message\UpdateRdapServers;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'app:update-rdap-servers',
|
||||
description: 'Updates the RDAP servers cache (requires MQ to be running)',
|
||||
)]
|
||||
class UpdateRdapServersCommand extends Command
|
||||
{
|
||||
public function __construct(private MessageBusInterface $bus)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$this->bus->dispatch(new UpdateRdapServers());
|
||||
|
||||
$io->success('Message sent!');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -369,13 +369,19 @@ readonly class RDAPService
|
||||
|
||||
foreach ($tldList as $tld) {
|
||||
if ($tld === "") continue;
|
||||
|
||||
$tldEntity = $this->tldRepository->findOneBy(['tld' => $tld]);
|
||||
if ($tldEntity === null) $tldEntity = new Tld();
|
||||
|
||||
if ($tldEntity === null) {
|
||||
$tldEntity = new Tld();
|
||||
$tldEntity->setTld($tld);
|
||||
}
|
||||
|
||||
$type = $this->getTldType($tld);
|
||||
|
||||
if ($type !== null) {
|
||||
$tldEntity->setType($type);
|
||||
} elseif ($tldEntity->isContractTerminated() === null) {
|
||||
} elseif ($tldEntity->isContractTerminated() === null) { // ICANN managed, must be a ccTLD
|
||||
$tldEntity->setType(TldType::ccTLD);
|
||||
} else {
|
||||
$tldEntity->setType(TldType::gTLD);
|
||||
@@ -415,18 +421,25 @@ readonly class RDAPService
|
||||
foreach ($gTldList as $gTld) {
|
||||
if ($gTld['gTLD'] === "") continue;
|
||||
/** @var Tld $gtTldEntity */
|
||||
$gtTldEntity = $this->em->getReference(Tld::class, $gTld['gTLD']);
|
||||
$gtTldEntity = $this->tldRepository->findOneBy([ 'tld' => $gTld['gTLD'] ]);
|
||||
|
||||
if (null == $gtTldEntity) {
|
||||
$gtTldEntity = new Tld();
|
||||
$gtTldEntity->setTld($gTld['gTLD']);
|
||||
}
|
||||
|
||||
$gtTldEntity
|
||||
->setContractTerminated($gTld['contractTerminated'])
|
||||
->setRegistryOperator($gTld['registryOperator'])
|
||||
->setSpecification13($gTld['specification13']);
|
||||
->setSpecification13($gTld['specification13'])
|
||||
->setType(TldType::gTLD);
|
||||
|
||||
if ($gTld['removalDate'] !== null) $gtTldEntity->setRemovalDate(new DateTimeImmutable($gTld['removalDate']));
|
||||
if ($gTld['delegationDate'] !== null) $gtTldEntity->setDelegationDate(new DateTimeImmutable($gTld['delegationDate']));
|
||||
if ($gTld['dateOfContractSignature'] !== null) $gtTldEntity->setDateOfContractSignature(new DateTimeImmutable($gTld['dateOfContractSignature']));
|
||||
$this->em->persist($gtTldEntity);
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user