mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 17:55:42 +00:00
feat: add delete property on DomainEntity
This commit is contained in:
parent
7bdb289461
commit
689ad51e3a
@ -27,6 +27,7 @@ export interface Event {
|
|||||||
export interface Entity {
|
export interface Entity {
|
||||||
handle: string
|
handle: string
|
||||||
jCard: any
|
jCard: any
|
||||||
|
deleted: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Nameserver {
|
export interface Nameserver {
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import {Domain} from "../api";
|
import {Domain} from "../api";
|
||||||
|
|
||||||
export const sortDomainEntities = (domain: Domain) => domain.entities.sort((e1, e2) => {
|
export const sortDomainEntities = (domain: Domain) => domain.entities
|
||||||
|
.filter(e => !e.entity.deleted)
|
||||||
|
.sort((e1, e2) => {
|
||||||
const p = (r: string[]) => r.includes('registrant') ? 5 :
|
const p = (r: string[]) => r.includes('registrant') ? 5 :
|
||||||
r.includes('administrative') ? 4 :
|
r.includes('administrative') ? 4 :
|
||||||
r.includes('billing') ? 3 :
|
r.includes('billing') ? 3 :
|
||||||
r.includes('registrar') ? 2 : 1
|
r.includes('registrar') ? 2 : 1
|
||||||
return p(e2.roles) - p(e1.roles)
|
return p(e2.roles) - p(e1.roles)
|
||||||
})
|
})
|
||||||
34
migrations/Version20240904155605.php
Normal file
34
migrations/Version20240904155605.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240904155605 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE domain_entity ADD deleted BOOLEAN NOT NULL DEFAULT FALSE');
|
||||||
|
$this->addSql('ALTER TABLE domain_entity DROP updated_at');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE domain_entity ADD updated_at DATE NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE domain_entity DROP deleted');
|
||||||
|
$this->addSql('COMMENT ON COLUMN domain_entity.updated_at IS \'(DC2Type:date_immutable)\'');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,13 +27,13 @@ class DomainEntity
|
|||||||
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
|
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
|
||||||
private array $roles = [];
|
private array $roles = [];
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
#[ORM\Column]
|
||||||
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
|
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
|
||||||
private ?\DateTimeImmutable $updatedAt = null;
|
private ?bool $deleted;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->updatedAt = new \DateTimeImmutable('now');
|
$this->deleted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDomain(): ?Domain
|
public function getDomain(): ?Domain
|
||||||
@ -75,22 +75,15 @@ class DomainEntity
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUpdatedAt(): ?\DateTimeImmutable
|
public function getDeleted(): ?bool
|
||||||
{
|
{
|
||||||
return $this->updatedAt;
|
return $this->deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUpdatedAt(\DateTimeImmutable $updatedAt): static
|
public function setDeleted(?bool $deleted): static
|
||||||
{
|
{
|
||||||
$this->updatedAt = $updatedAt;
|
$this->deleted = $deleted;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ORM\PrePersist]
|
|
||||||
#[ORM\PreUpdate]
|
|
||||||
public function updateTimestamps(): void
|
|
||||||
{
|
|
||||||
$this->setUpdatedAt(new \DateTimeImmutable('now'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -244,6 +244,11 @@ readonly class RDAPService
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var DomainEntity $domainEntity */
|
||||||
|
foreach ($domain->getDomainEntities()->getIterator() as $domainEntity) {
|
||||||
|
$domainEntity->setDeleted(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('entities', $res) && is_array($res['entities'])) {
|
if (array_key_exists('entities', $res) && is_array($res['entities'])) {
|
||||||
foreach ($res['entities'] as $rdapEntity) {
|
foreach ($res['entities'] as $rdapEntity) {
|
||||||
if (!array_key_exists('handle', $rdapEntity) || '' === $rdapEntity['handle']) {
|
if (!array_key_exists('handle', $rdapEntity) || '' === $rdapEntity['handle']) {
|
||||||
@ -282,8 +287,9 @@ readonly class RDAPService
|
|||||||
$domain->addDomainEntity($domainEntity
|
$domain->addDomainEntity($domainEntity
|
||||||
->setDomain($domain)
|
->setDomain($domain)
|
||||||
->setEntity($entity)
|
->setEntity($entity)
|
||||||
->setRoles($roles))
|
->setRoles($roles)
|
||||||
->updateTimestamps();
|
->setDeleted(false)
|
||||||
|
);
|
||||||
|
|
||||||
$this->em->persist($domainEntity);
|
$this->em->persist($domainEntity);
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user