mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
fix: update RDAPService parser
This commit is contained in:
@@ -23,7 +23,7 @@ class DomainEntity
|
||||
#[Groups(['domain-entity:entity'])]
|
||||
private ?Entity $entity = null;
|
||||
|
||||
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainRole::class)]
|
||||
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
|
||||
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
|
||||
private array $roles = [];
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ class Event
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(enumType: EventAction::class)]
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['event:list'])]
|
||||
private ?EventAction $action = null;
|
||||
private ?string $action = null;
|
||||
|
||||
#[ORM\Column(type: 'datetime_immutable')]
|
||||
#[Groups(['event:list'])]
|
||||
@@ -29,12 +29,12 @@ class Event
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getAction(): ?EventAction
|
||||
public function getAction(): ?string
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
public function setAction(EventAction $action): static
|
||||
public function setAction(string $action): static
|
||||
{
|
||||
$this->action = $action;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class NameserverEntity
|
||||
private ?Entity $entity = null;
|
||||
|
||||
|
||||
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainRole::class)]
|
||||
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
|
||||
#[Groups(['nameserver-entity:entity', 'nameserver-entity:nameserver'])]
|
||||
private array $roles = [];
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
class WatchListTrigger
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(enumType: EventAction::class)]
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['watchlist:item', 'watchlist:create', 'watchlist:update'])]
|
||||
private ?EventAction $event = null;
|
||||
private ?string $event = null;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\ManyToOne(targetEntity: WatchList::class, inversedBy: 'watchListTriggers')]
|
||||
@@ -26,12 +26,12 @@ class WatchListTrigger
|
||||
#[Groups(['watchlist:item', 'watchlist:create', 'watchlist:update'])]
|
||||
private ?TriggerAction $action = null;
|
||||
|
||||
public function getEvent(): ?EventAction
|
||||
public function getEvent(): ?string
|
||||
{
|
||||
return $this->event;
|
||||
}
|
||||
|
||||
public function setEvent(EventAction $event): static
|
||||
public function setEvent(string $event): static
|
||||
{
|
||||
$this->event = $event;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Config\DomainRole;
|
||||
use App\Config\EventAction;
|
||||
use App\Entity\Domain;
|
||||
use App\Entity\DomainEntity;
|
||||
@@ -99,18 +98,17 @@ readonly class RDAPService
|
||||
$this->em->flush();
|
||||
|
||||
foreach ($res['events'] as $rdapEvent) {
|
||||
$eventAction = EventAction::from($rdapEvent['eventAction']);
|
||||
if ($eventAction === EventAction::LastUpdateOfRDAPDatabase) continue;
|
||||
if ($rdapEvent['eventAction'] === EventAction::LastUpdateOfRDAPDatabase->value) continue;
|
||||
|
||||
$event = $this->domainEventRepository->findOneBy([
|
||||
"action" => $eventAction,
|
||||
"action" => $rdapEvent['eventAction'],
|
||||
"date" => new DateTimeImmutable($rdapEvent["eventDate"]),
|
||||
"domain" => $domain
|
||||
]);
|
||||
|
||||
if ($event === null) $event = new DomainEvent();
|
||||
$domain->addEvent($event
|
||||
->setAction($eventAction)
|
||||
->setAction($rdapEvent['eventAction'])
|
||||
->setDate(new DateTimeImmutable($rdapEvent['eventDate'])));
|
||||
|
||||
}
|
||||
@@ -130,20 +128,20 @@ readonly class RDAPService
|
||||
|
||||
if ($domainEntity === null) $domainEntity = new DomainEntity();
|
||||
|
||||
$roles = array_merge(
|
||||
...array_map(
|
||||
fn(array $e): array => $e['roles'],
|
||||
array_filter(
|
||||
$res['entities'],
|
||||
fn($e) => array_key_exists('handle', $e) && $e['handle'] === $rdapEntity['handle']
|
||||
)
|
||||
$roles = array_map(
|
||||
fn($e) => $e['roles'],
|
||||
array_filter(
|
||||
$res['entities'],
|
||||
fn($e) => array_key_exists('handle', $e) && $e['handle'] === $rdapEntity['handle']
|
||||
)
|
||||
);
|
||||
|
||||
if (count($roles) !== count($roles, COUNT_RECURSIVE)) $roles = array_merge(...$roles);
|
||||
|
||||
$domain->addDomainEntity($domainEntity
|
||||
->setDomain($domain)
|
||||
->setEntity($entity)
|
||||
->setRoles(array_map(fn($str): DomainRole => DomainRole::from($str), $roles)));
|
||||
->setRoles($roles));
|
||||
|
||||
$this->em->persist($domainEntity);
|
||||
$this->em->flush();
|
||||
@@ -191,7 +189,7 @@ readonly class RDAPService
|
||||
->setNameserver($nameserver)
|
||||
->setEntity($entity)
|
||||
->setStatus($rdapNameserver['status'])
|
||||
->setRoles(array_map(fn($str): DomainRole => DomainRole::from($str), $roles)));
|
||||
->setRoles($roles));
|
||||
}
|
||||
|
||||
$domain->addNameserver($nameserver);
|
||||
@@ -232,27 +230,28 @@ readonly class RDAPService
|
||||
|
||||
$entity->setHandle($rdapEntity['handle']);
|
||||
|
||||
if (empty($entity->getJCard())) {
|
||||
$entity->setJCard($rdapEntity['vcardArray']);
|
||||
} else {
|
||||
$properties = [];
|
||||
foreach ($rdapEntity['vcardArray'][1] as $prop) {
|
||||
$properties[$prop[0]] = $prop;
|
||||
if (array_key_exists('vcardArray', $rdapEntity)) {
|
||||
if (empty($entity->getJCard())) {
|
||||
$entity->setJCard($rdapEntity['vcardArray']);
|
||||
} else {
|
||||
$properties = [];
|
||||
foreach ($rdapEntity['vcardArray'][1] as $prop) {
|
||||
$properties[$prop[0]] = $prop;
|
||||
}
|
||||
foreach ($entity->getJCard()[1] as $prop) {
|
||||
$properties[$prop[0]] = $prop;
|
||||
}
|
||||
$entity->setJCard(["vcard", array_values($properties)]);
|
||||
}
|
||||
foreach ($entity->getJCard()[1] as $prop) {
|
||||
$properties[$prop[0]] = $prop;
|
||||
}
|
||||
$entity->setJCard(["vcard", array_values($properties)]);
|
||||
}
|
||||
|
||||
|
||||
if (!array_key_exists('events', $rdapEntity)) return $entity;
|
||||
|
||||
foreach ($rdapEntity['events'] as $rdapEntityEvent) {
|
||||
$eventAction = $rdapEntityEvent["eventAction"];
|
||||
if ($eventAction === EventAction::LastChanged->value || $eventAction === EventAction::LastUpdateOfRDAPDatabase->value) continue;
|
||||
$event = $this->entityEventRepository->findOneBy([
|
||||
"action" => EventAction::from($rdapEntityEvent["eventAction"]),
|
||||
"action" => $rdapEntityEvent["eventAction"],
|
||||
"date" => new DateTimeImmutable($rdapEntityEvent["eventDate"])
|
||||
]);
|
||||
|
||||
@@ -260,7 +259,7 @@ readonly class RDAPService
|
||||
$entity->addEvent(
|
||||
(new EntityEvent())
|
||||
->setEntity($entity)
|
||||
->setAction(EventAction::from($rdapEntityEvent['eventAction']))
|
||||
->setAction($rdapEntityEvent["eventAction"])
|
||||
->setDate(new DateTimeImmutable($rdapEntityEvent['eventDate'])));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user