725 lines
21 KiB
PHP
Raw Normal View History

2024-07-10 23:30:59 +02:00
<?php
namespace App\Entity;
2024-07-17 00:19:27 +02:00
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
2025-09-13 13:09:28 +02:00
use ApiPlatform\Metadata\Post;
2024-12-07 20:08:29 +01:00
use App\Config\EventAction;
2024-07-17 18:18:11 +02:00
use App\Controller\DomainRefreshController;
2025-09-13 13:09:28 +02:00
use App\Controller\ProposeDomainController;
2024-07-10 23:30:59 +02:00
use App\Repository\DomainRepository;
2025-05-21 13:14:38 +02:00
use App\Service\RDAPService;
use App\State\AutoRegisterDomainProvider;
2024-07-10 23:30:59 +02:00
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
2025-04-27 12:13:06 +02:00
use Eluceo\iCal\Domain\Entity\Attendee;
use Eluceo\iCal\Domain\Entity\Event;
use Eluceo\iCal\Domain\Enum\EventStatus;
use Eluceo\iCal\Domain\ValueObject\Category;
use Eluceo\iCal\Domain\ValueObject\Date;
use Eluceo\iCal\Domain\ValueObject\EmailAddress;
use Eluceo\iCal\Domain\ValueObject\SingleDay;
use Eluceo\iCal\Domain\ValueObject\Timestamp;
use Sabre\VObject\EofException;
use Sabre\VObject\InvalidDataException;
use Sabre\VObject\ParseException;
use Sabre\VObject\Reader;
2024-07-17 00:19:27 +02:00
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Attribute\SerializedName;
2024-07-10 23:30:59 +02:00
#[ORM\Entity(repositoryClass: DomainRepository::class)]
2024-07-17 00:19:27 +02:00
#[ApiResource(
operations: [
2024-07-24 13:46:10 +02:00
/*
2024-07-17 14:00:46 +02:00
new GetCollection(
normalizationContext: [
'groups' => [
'domain:list'
]
]
),
2024-07-24 13:46:10 +02:00
*/
2024-07-17 00:19:27 +02:00
new Get(
2024-08-02 23:24:52 +02:00
uriTemplate: '/domains/{ldhName}', // Do not delete this line, otherwise Symfony interprets the TLD of the domain name as a return type
controller: DomainRefreshController::class,
2024-07-17 14:00:46 +02:00
normalizationContext: [
'groups' => [
'domain:item',
'event:list',
'domain-entity:entity',
2024-07-18 03:03:46 +02:00
'nameserver-entity:nameserver',
'nameserver-entity:entity',
2024-08-02 23:24:52 +02:00
'tld:item',
2025-08-26 16:18:29 +02:00
'ds:list',
2024-08-02 23:24:52 +02:00
],
2024-07-17 18:18:11 +02:00
],
read: false
2024-08-02 23:24:52 +02:00
),
2025-09-13 13:09:28 +02:00
new Post(
uriTemplate: '/propose-domain/{ldhName}',
controller: ProposeDomainController::class,
shortName: 'Propose Domain',
input: false,
read: false,
write: false,
),
],
provider: AutoRegisterDomainProvider::class
2024-07-17 00:19:27 +02:00
)]
2024-07-10 23:30:59 +02:00
class Domain
{
2024-07-13 12:49:11 +02:00
#[ORM\Id]
2024-07-10 23:30:59 +02:00
#[ORM\Column(length: 255)]
2024-07-27 20:44:10 +02:00
#[Groups(['domain:item', 'domain:list', 'watchlist:item', 'watchlist:list'])]
2024-07-11 17:01:16 +02:00
private ?string $ldhName = null;
2024-07-10 23:30:59 +02:00
#[ORM\Column(length: 255, nullable: true)]
2024-07-18 13:40:49 +02:00
#[Groups(['domain:item', 'domain:list', 'watchlist:item'])]
2024-07-10 23:30:59 +02:00
private ?string $handle = null;
/**
2024-07-11 17:01:16 +02:00
* @var Collection<int, DomainEvent>
2024-07-10 23:30:59 +02:00
*/
2024-07-12 00:50:30 +02:00
#[ORM\OneToMany(targetEntity: DomainEvent::class, mappedBy: 'domain', cascade: ['persist'], orphanRemoval: true)]
2025-04-02 18:36:35 +02:00
#[Groups(['domain:item', 'domain:list', 'watchlist:list'])]
2024-07-10 23:30:59 +02:00
private Collection $events;
/**
* @var Collection<int, DomainEntity>
*/
2024-07-12 00:50:30 +02:00
#[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'domain', cascade: ['persist'], orphanRemoval: true)]
2024-07-17 00:19:27 +02:00
#[Groups(['domain:item'])]
#[SerializedName('entities')]
2024-07-10 23:30:59 +02:00
private Collection $domainEntities;
2024-07-23 14:30:21 +02:00
#[ORM\Column(type: Types::SIMPLE_ARRAY, nullable: true)]
#[Groups(['domain:item', 'domain:list', 'watchlist:item', 'watchlist:list'])]
2024-07-11 13:15:04 +02:00
private array $status = [];
2024-07-11 22:20:20 +02:00
/**
2024-07-12 15:20:24 +02:00
* @var Collection<int, WatchList>
2024-07-11 22:20:20 +02:00
*/
2024-07-12 15:20:24 +02:00
#[ORM\ManyToMany(targetEntity: WatchList::class, mappedBy: 'domains', cascade: ['persist'])]
private Collection $watchLists;
2024-07-11 22:20:20 +02:00
2024-07-11 17:01:16 +02:00
/**
* @var Collection<int, Nameserver>
*/
2024-07-12 00:50:30 +02:00
#[ORM\ManyToMany(targetEntity: Nameserver::class, inversedBy: 'domains', cascade: ['persist'])]
2024-07-11 22:20:20 +02:00
#[ORM\JoinTable(name: 'domain_nameservers',
2024-07-13 15:52:52 +02:00
joinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'nameserver_ldh_name', referencedColumnName: 'ldh_name')]
2024-07-11 22:20:20 +02:00
)]
2024-07-17 00:19:27 +02:00
#[Groups(['domain:item'])]
2024-07-11 17:01:16 +02:00
private Collection $nameservers;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
private ?\DateTimeImmutable $createdAt;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
2024-09-09 11:31:33 +02:00
#[Groups(['domain:item', 'domain:list'])]
private ?\DateTimeImmutable $updatedAt;
2024-07-19 18:59:21 +02:00
#[ORM\ManyToOne]
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)]
2024-09-09 11:31:33 +02:00
#[Groups(['domain:item', 'domain:list'])]
2024-07-19 18:59:21 +02:00
private ?Tld $tld = null;
2024-09-01 21:26:07 +02:00
#[ORM\Column(nullable: false)]
#[Groups(['domain:item', 'domain:list', 'watchlist:item', 'watchlist:list'])]
2024-09-01 21:26:07 +02:00
private ?bool $deleted;
2024-07-25 16:19:57 +02:00
#[Groups(['domain:item'])]
private ?RdapServer $rdapServer;
/**
* @var Collection<int, DomainStatus>
*/
#[ORM\OneToMany(targetEntity: DomainStatus::class, mappedBy: 'domain', orphanRemoval: true)]
2024-12-22 22:13:27 +01:00
#[Groups(['domain:item'])]
#[SerializedName('oldStatus')]
private Collection $domainStatuses;
2025-02-18 01:29:29 +01:00
#[ORM\Column(nullable: false, options: ['default' => false])]
#[Groups(['domain:item', 'domain:list'])]
private ?bool $delegationSigned = null;
2025-08-26 16:18:29 +02:00
/**
* @var Collection<int, DnsKey>
*/
#[ORM\OneToMany(targetEntity: DnsKey::class, mappedBy: 'domain', orphanRemoval: true)]
#[Groups(['domain:item'])]
private Collection $dnsKey;
2024-12-07 20:08:29 +01:00
private const IMPORTANT_EVENTS = [EventAction::Deletion->value, EventAction::Expiration->value];
private const IMPORTANT_STATUS = [
'redemption period',
'pending delete',
'pending create',
'pending renew',
'pending restore',
'pending transfer',
'pending update',
'add period',
];
2024-07-10 23:30:59 +02:00
public function __construct()
{
$this->events = new ArrayCollection();
$this->domainEntities = new ArrayCollection();
2024-07-12 15:20:24 +02:00
$this->watchLists = new ArrayCollection();
2024-07-11 17:01:16 +02:00
$this->nameservers = new ArrayCollection();
2024-08-02 23:24:52 +02:00
$this->updatedAt = new \DateTimeImmutable('now');
$this->createdAt = $this->updatedAt;
2024-07-25 16:19:57 +02:00
$this->deleted = false;
$this->domainStatuses = new ArrayCollection();
2025-08-26 16:18:29 +02:00
$this->dnsKey = new ArrayCollection();
2024-07-10 23:30:59 +02:00
}
2024-07-11 17:01:16 +02:00
public function getLdhName(): ?string
2024-07-10 23:30:59 +02:00
{
2024-07-11 17:01:16 +02:00
return $this->ldhName;
2024-07-10 23:30:59 +02:00
}
2024-07-11 17:01:16 +02:00
public function setLdhName(string $ldhName): static
2024-07-10 23:30:59 +02:00
{
2025-05-21 13:14:38 +02:00
$this->ldhName = RDAPService::convertToIdn($ldhName);
2024-07-10 23:30:59 +02:00
return $this;
}
public function getHandle(): ?string
{
return $this->handle;
}
public function setHandle(string $handle): static
{
$this->handle = $handle;
return $this;
}
/**
2024-07-11 17:01:16 +02:00
* @return Collection<int, DomainEvent>
2024-07-10 23:30:59 +02:00
*/
public function getEvents(): Collection
{
return $this->events;
}
2024-07-11 17:01:16 +02:00
public function addEvent(DomainEvent $event): static
2024-07-10 23:30:59 +02:00
{
if (!$this->events->contains($event)) {
$this->events->add($event);
$event->setDomain($this);
}
return $this;
}
2024-07-11 17:01:16 +02:00
public function removeEvent(DomainEvent $event): static
2024-07-10 23:30:59 +02:00
{
if ($this->events->removeElement($event)) {
// set the owning side to null (unless already changed)
if ($event->getDomain() === $this) {
$event->setDomain(null);
}
}
return $this;
}
/**
* @return Collection<int, DomainEntity>
*/
public function getDomainEntities(): Collection
{
return $this->domainEntities;
}
public function addDomainEntity(DomainEntity $domainEntity): static
{
if (!$this->domainEntities->contains($domainEntity)) {
$this->domainEntities->add($domainEntity);
$domainEntity->setDomain($this);
}
return $this;
}
public function removeDomainEntity(DomainEntity $domainEntity): static
{
if ($this->domainEntities->removeElement($domainEntity)) {
// set the owning side to null (unless already changed)
if ($domainEntity->getDomain() === $this) {
$domainEntity->setDomain(null);
}
}
return $this;
}
2024-07-11 13:15:04 +02:00
public function getStatus(): array
{
return $this->status;
}
public function setStatus(array $status): static
{
$this->status = $status;
return $this;
}
2024-07-11 17:01:16 +02:00
2024-07-11 22:20:20 +02:00
/**
2024-07-12 15:20:24 +02:00
* @return Collection<int, WatchList>
2024-07-11 22:20:20 +02:00
*/
2024-07-12 15:20:24 +02:00
public function getWatchLists(): Collection
2024-07-11 22:20:20 +02:00
{
2024-07-12 15:20:24 +02:00
return $this->watchLists;
2024-07-11 22:20:20 +02:00
}
2024-07-12 15:20:24 +02:00
public function addWatchList(WatchList $watchList): static
2024-07-11 22:20:20 +02:00
{
2024-07-12 15:20:24 +02:00
if (!$this->watchLists->contains($watchList)) {
$this->watchLists->add($watchList);
$watchList->addDomain($this);
2024-07-11 22:20:20 +02:00
}
return $this;
}
2024-07-12 15:20:24 +02:00
public function removeWatchList(WatchList $watchList): static
2024-07-11 22:20:20 +02:00
{
2024-07-12 15:20:24 +02:00
if ($this->watchLists->removeElement($watchList)) {
$watchList->removeDomain($this);
2024-07-11 22:20:20 +02:00
}
return $this;
}
2024-07-11 17:01:16 +02:00
/**
* @return Collection<int, Nameserver>
*/
public function getNameservers(): Collection
{
return $this->nameservers;
}
public function addNameserver(Nameserver $nameserver): static
{
if (!$this->nameservers->contains($nameserver)) {
$this->nameservers->add($nameserver);
}
return $this;
}
public function removeNameserver(Nameserver $nameserver): static
{
$this->nameservers->removeElement($nameserver);
return $this;
}
2024-08-02 23:24:52 +02:00
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
#[ORM\PrePersist]
#[ORM\PreUpdate]
2024-12-20 22:25:41 +01:00
public function updateTimestamps(): static
{
2024-08-02 23:24:52 +02:00
$this->setUpdatedAt(new \DateTimeImmutable('now'));
if (null === $this->getCreatedAt()) {
$this->setCreatedAt($this->getUpdatedAt());
}
2024-12-20 22:25:41 +01:00
return $this;
}
2024-08-02 23:24:52 +02:00
private function setUpdatedAt(?\DateTimeImmutable $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
2024-08-02 23:24:52 +02:00
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
2024-08-02 23:24:52 +02:00
private function setCreatedAt(?\DateTimeImmutable $createdAt): void
{
$this->createdAt = $createdAt;
}
2024-07-19 18:59:21 +02:00
public function getTld(): ?Tld
{
return $this->tld;
}
public function setTld(?Tld $tld): static
{
$this->tld = $tld;
return $this;
}
2024-07-25 16:19:57 +02:00
public function getDeleted(): ?bool
{
return $this->deleted;
}
public function setDeleted(?bool $deleted): static
{
$this->deleted = $deleted;
return $this;
}
2024-12-07 20:08:29 +01:00
/**
* Determines if a domain name needs special attention.
* These domain names are those whose last event was expiration or deletion.
*
* @throws \Exception
*/
2025-09-09 19:43:35 +02:00
protected function isToBeWatchClosely(): bool
2024-12-07 20:08:29 +01:00
{
$status = $this->getStatus();
if ((!empty($status) && count(array_intersect($status, self::IMPORTANT_STATUS))) || $this->getDeleted()) {
return true;
}
/** @var DomainEvent[] $events */
$events = $this->getEvents()
->filter(fn (DomainEvent $e) => !$e->getDeleted() && $e->getDate() <= new \DateTimeImmutable('now'))
2024-12-07 20:08:29 +01:00
->toArray();
usort($events, fn (DomainEvent $e1, DomainEvent $e2) => $e2->getDate() <=> $e1->getDate());
return !empty($events) && in_array($events[0]->getAction(), self::IMPORTANT_EVENTS);
}
/**
* Returns true if one or more of these conditions are met:
* - It has been more than 7 days since the domain name was last updated
2025-01-04 19:35:55 +01:00
* - It has been more than 12 minutes and the domain name has statuses that suggest it is not stable
2024-12-07 20:08:29 +01:00
* - It has been more than 1 day and the domain name is blocked in DNS
*
* @throws \Exception
*/
2025-04-06 15:25:38 +02:00
public function isToBeUpdated(bool $fromUser = true, bool $intensifyLastDay = false): bool
2024-12-07 20:08:29 +01:00
{
2025-01-14 22:00:45 +01:00
$updatedAtDiff = $this->getUpdatedAt()->diff(new \DateTimeImmutable());
if ($updatedAtDiff->days >= 7) {
return true;
}
if ($this->getDeleted()) {
return $fromUser;
}
$expiresIn = $this->getExpiresInDays();
2025-04-06 15:25:38 +02:00
if ($intensifyLastDay && (0 === $expiresIn || 1 === $expiresIn)) {
2025-01-14 22:00:45 +01:00
return true;
}
$minutesDiff = $updatedAtDiff->h * 60 + $updatedAtDiff->i;
if (($minutesDiff >= 12 || $fromUser) && $this->isToBeWatchClosely()) {
return true;
}
if (
count(array_intersect($this->getStatus(), ['auto renew period', 'client hold', 'server hold'])) > 0
&& $updatedAtDiff->days >= 1
) {
return true;
}
return false;
2024-12-07 20:08:29 +01:00
}
/**
* @return Collection<int, DomainStatus>
*/
public function getDomainStatuses(): Collection
{
return $this->domainStatuses;
}
public function addDomainStatus(DomainStatus $domainStatus): static
{
if (!$this->domainStatuses->contains($domainStatus)) {
$this->domainStatuses->add($domainStatus);
$domainStatus->setDomain($this);
}
return $this;
}
public function removeDomainStatus(DomainStatus $domainStatus): static
{
if ($this->domainStatuses->removeElement($domainStatus)) {
// set the owning side to null (unless already changed)
if ($domainStatus->getDomain() === $this) {
$domainStatus->setDomain(null);
}
}
return $this;
}
public function getRdapServer(): ?RdapServer
{
return $this->rdapServer;
}
public function setRdapServer(?RdapServer $rdapServer): static
{
$this->rdapServer = $rdapServer;
return $this;
}
public function isDelegationSigned(): ?bool
{
return $this->delegationSigned;
}
public function setDelegationSigned(bool $delegationSigned): static
{
$this->delegationSigned = $delegationSigned;
return $this;
}
2025-01-17 12:39:50 +01:00
public function isRedemptionPeriod(): bool
{
return in_array('redemption period', $this->getStatus());
}
public function isPendingDelete(): bool
{
return in_array('pending delete', $this->getStatus()) && !in_array('redemption period', $this->getStatus());
}
2025-01-20 17:30:54 +01:00
/**
* @throws \DateMalformedIntervalStringException
*/
2025-01-23 00:31:37 +01:00
private function calculateDaysFromStatus(\DateTimeImmutable $now): ?int
2025-01-17 12:39:50 +01:00
{
2025-01-23 00:31:37 +01:00
$lastStatus = $this->getDomainStatuses()->last();
if (false === $lastStatus) {
return null;
}
2025-04-02 13:39:32 +02:00
if ($this->isPendingDelete() && (
in_array('pending delete', $lastStatus->getAddStatus())
|| in_array('redemption period', $lastStatus->getDeleteStatus()))
) {
return self::daysBetween($now, $lastStatus->getCreatedAt()->add(new \DateInterval('P'. 5 .'D')));
2025-01-17 12:39:50 +01:00
}
2025-04-02 13:39:32 +02:00
if ($this->isRedemptionPeriod()
&& in_array('redemption period', $lastStatus->getAddStatus())
) {
return self::daysBetween($now, $lastStatus->getCreatedAt()->add(new \DateInterval('P'.(30 + 5).'D')));
2025-01-17 12:39:50 +01:00
}
return null;
}
2025-01-23 00:31:37 +01:00
/*
private function calculateDaysFromEvents(\DateTimeImmutable $now): ?int
{
$lastChangedEvent = $this->getEvents()->findFirst(fn (int $i, DomainEvent $e) => !$e->getDeleted() && EventAction::LastChanged->value === $e->getAction());
if (null === $lastChangedEvent) {
return null;
}
if ($this->isRedemptionPeriod()) {
return self::daysBetween($now, $lastChangedEvent->getDate()->add(new \DateInterval('P'.(30 + 5).'D')));
2025-01-23 00:31:37 +01:00
}
if ($this->isPendingDelete()) {
return self::daysBetween($now, $lastChangedEvent->getDate()->add(new \DateInterval('P'. 5 .'D')));
2025-01-23 00:31:37 +01:00
}
return null;
}
*/
private static function daysBetween(\DateTimeImmutable $start, \DateTimeImmutable $end): int
{
$interval = $start->setTime(0, 0)->diff($end->setTime(0, 0));
return $interval->invert ? -$interval->days : $interval->days;
}
2025-01-23 00:31:37 +01:00
private static function returnExpiresIn(array $guesses): ?int
2025-01-17 12:39:50 +01:00
{
2025-01-23 00:31:37 +01:00
$filteredGuesses = array_filter($guesses, function ($value) {
2025-02-08 11:53:08 +01:00
return null !== $value;
2025-01-23 00:31:37 +01:00
});
if (empty($filteredGuesses)) {
return null;
}
2025-02-08 11:53:08 +01:00
return max(min($filteredGuesses), 0);
2025-01-17 12:39:50 +01:00
}
/**
* @throws \Exception
*/
private function getRelevantDates(): array
{
$expiredAt = $deletedAt = null;
foreach ($this->getEvents()->getIterator() as $event) {
if (!$event->getDeleted()) {
if ('expiration' === $event->getAction()) {
$expiredAt = $event->getDate();
2025-01-17 18:18:55 +01:00
} elseif ('deletion' === $event->getAction()) {
2025-01-17 12:39:50 +01:00
$deletedAt = $event->getDate();
}
}
}
return [$expiredAt, $deletedAt];
}
2025-01-02 17:16:20 +01:00
/**
* @throws \Exception
*/
2025-01-04 01:19:40 +01:00
#[Groups(['domain:item', 'domain:list'])]
public function getExpiresInDays(): ?int
{
2025-01-29 20:43:26 +01:00
if ($this->getDeleted()) {
return null;
}
$now = new \DateTimeImmutable();
2025-01-17 12:39:50 +01:00
[$expiredAt, $deletedAt] = $this->getRelevantDates();
2025-01-23 00:36:28 +01:00
if ($expiredAt) {
$guess = self::daysBetween($now, $expiredAt->add(new \DateInterval('P'.(45 + 30 + 5).'D')));
2025-01-23 00:36:28 +01:00
}
if ($deletedAt) {
2025-01-20 17:30:54 +01:00
// It has been observed that AFNIC, on the last day, adds a "deleted" event and removes the redemption period status.
2025-01-23 00:31:37 +01:00
if (0 === self::daysBetween($now, $deletedAt) && $this->isPendingDelete()) {
2025-01-17 18:18:55 +01:00
return 0;
}
2025-01-20 17:30:54 +01:00
$guess = self::daysBetween($now, $deletedAt->add(new \DateInterval('P'. 30 .'D')));
}
2025-01-17 12:39:50 +01:00
2025-01-23 00:31:37 +01:00
return self::returnExpiresIn([
$guess ?? null,
$this->calculateDaysFromStatus($now),
]);
}
2025-04-27 12:13:06 +02:00
2025-08-26 16:18:29 +02:00
/**
* @return Collection<int, DnsKey>
*/
public function getDnsKey(): Collection
{
return $this->dnsKey;
}
public function addDnsKey(DnsKey $dnsKey): static
{
if (!$this->dnsKey->contains($dnsKey)) {
$this->dnsKey->add($dnsKey);
$dnsKey->setDomain($this);
}
return $this;
}
public function removeDnsKey(DnsKey $dnsKey): static
{
if ($this->dnsKey->removeElement($dnsKey)) {
// set the owning side to null (unless already changed)
if ($dnsKey->getDomain() === $this) {
$dnsKey->setDomain(null);
}
}
return $this;
}
2025-08-26 16:46:05 +02:00
2025-04-27 12:13:06 +02:00
/**
2025-08-06 19:44:11 +02:00
* @return Event[]
*
2025-04-27 12:13:06 +02:00
* @throws ParseException
* @throws EofException
* @throws InvalidDataException
2025-05-21 13:20:04 +02:00
* @throws \Exception
2025-04-27 12:13:06 +02:00
*/
public function getDomainCalendarEvents(): array
{
$events = [];
$attendees = [];
/* @var DomainEntity $entity */
foreach ($this->getDomainEntities()->filter(fn (DomainEntity $domainEntity) => !$domainEntity->getDeleted())->getIterator() as $domainEntity) {
$jCard = $domainEntity->getEntity()->getJCard();
if (empty($jCard)) {
continue;
}
$vCardData = Reader::readJson($jCard);
if (empty($vCardData->EMAIL) || empty($vCardData->FN)) {
continue;
}
$email = (string) $vCardData->EMAIL;
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
continue;
}
$attendees[] = (new Attendee(new EmailAddress($email)))->setDisplayName((string) $vCardData->FN);
}
/** @var DomainEvent $event */
foreach ($this->getEvents()->filter(fn (DomainEvent $e) => $e->getDate()->diff(new \DateTimeImmutable('now'))->y <= 10)->getIterator() as $event) {
$events[] = (new Event())
->setLastModified(new Timestamp($this->getUpdatedAt()))
->setStatus(EventStatus::CONFIRMED())
->setSummary($this->getLdhName().': '.$event->getAction())
->addCategory(new Category($event->getAction()))
->setAttendees($attendees)
->setOccurrence(new SingleDay(new Date($event->getDate()))
2025-05-21 13:20:04 +02:00
);
2025-04-27 12:13:06 +02:00
}
$expiresInDays = $this->getExpiresInDays();
if (null !== $expiresInDays) {
$events[] = (new Event())
->setLastModified(new Timestamp($this->getUpdatedAt()))
->setStatus(EventStatus::CONFIRMED())
2025-05-21 13:20:04 +02:00
->setSummary($this->getLdhName().': estimated WHOIS release date')
2025-04-27 12:13:06 +02:00
->addCategory(new Category('release'))
->setAttendees($attendees)
->setOccurrence(new SingleDay(new Date(
2025-05-21 13:20:04 +02:00
(new \DateTimeImmutable())->setTime(0, 0)->add(new \DateInterval('P'.$expiresInDays.'D'))
))
2025-04-27 12:13:06 +02:00
);
}
2025-05-21 13:20:04 +02:00
2025-04-27 12:13:06 +02:00
return $events;
}
2024-07-10 23:30:59 +02:00
}