feat: add estimated days before WHOIS release

This commit is contained in:
Maël Gangloff 2025-01-01 22:00:05 +01:00
parent 3605f88a7c
commit 18acd41b29
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
4 changed files with 75 additions and 15 deletions

View File

@ -97,6 +97,14 @@ export function TrackedDomainTable() {
icon={<KeyOutlined/>} icon={<KeyOutlined/>}
/> />
</Tooltip> </Tooltip>
{
d.expiresInDays && <Tooltip title={t`Estimated number of days until release`}>
<Tag bordered={false}
color={d.expiresInDays <= 5 ? 'red' : d.expiresInDays <= 35 ? 'orange' : 'default'}>
{t`J ${d.expiresInDays}`}
</Tag>
</Tooltip>
}
</Flex> </Flex>
} }
})) }))
@ -116,13 +124,13 @@ export function TrackedDomainTable() {
{ {
title: t`Domain`, title: t`Domain`,
dataIndex: 'ldhName', dataIndex: 'ldhName',
width: '30%', width: '25%',
align: 'left' align: 'left'
}, },
{ {
title: t`Options`, title: t`Options`,
dataIndex: 'options', dataIndex: 'options',
width: '10%', width: '15%',
}, },
{ {
title: t`Expiration date`, title: t`Expiration date`,

View File

@ -66,6 +66,7 @@ export interface Domain {
deleted: boolean deleted: boolean
updatedAt: string updatedAt: string
delegationSigned: boolean delegationSigned: boolean
expiresInDays?: number
} }
export interface User { export interface User {

View File

@ -121,6 +121,9 @@ class Domain
#[Groups(['domain:item', 'domain:list'])] #[Groups(['domain:item', 'domain:list'])]
private ?bool $delegationSigned = null; private ?bool $delegationSigned = null;
#[Groups(['domain:item', 'domain:list'])]
private ?int $expiresInDays = null;
private const IMPORTANT_EVENTS = [EventAction::Deletion->value, EventAction::Expiration->value]; private const IMPORTANT_EVENTS = [EventAction::Deletion->value, EventAction::Expiration->value];
private const IMPORTANT_STATUS = [ private const IMPORTANT_STATUS = [
'redemption period', 'redemption period',
@ -135,6 +138,8 @@ class Domain
'server hold', 'server hold',
]; ];
private const DAY = 24 * 60 * 60;
public function __construct() public function __construct()
{ {
$this->events = new ArrayCollection(); $this->events = new ArrayCollection();
@ -454,4 +459,41 @@ class Domain
return $this; return $this;
} }
private static function daysBetween(\DateTimeImmutable $start, \DateTimeImmutable $end): int
{
$interval = $start->diff($end);
return $interval->invert ? -$interval->days : $interval->days;
}
public function getExpiresInDays(): ?int
{
$now = new \DateTimeImmutable();
$lastStatus = $this->getDomainStatuses()->last();
if ($lastStatus) {
if (in_array('pending delete', $lastStatus->getAddStatus())) {
return self::daysBetween($now, $lastStatus->getCreatedAt()->add(new \DateInterval('P5D')));
}
if (in_array('redemption period', $lastStatus->getAddStatus())) {
return self::daysBetween($now, $lastStatus->getCreatedAt()->add(new \DateInterval('P35D')));
}
}
$expiredAt = null;
$deletedAt = null;
foreach ($this->getEvents() as $event) {
$expiredAt = !$event->getDeleted() && 'expiration' === $event->getAction() ? $event->getDate() : $expiredAt;
$deletedAt = !$event->getDeleted() && 'deletion' === $event->getAction() ? $event->getDate() : $deletedAt;
}
if ($deletedAt) {
return self::daysBetween($now, $deletedAt->add(new \DateInterval('P30D')));
}
if ($expiredAt) {
return self::daysBetween($now, $expiredAt->add(new \DateInterval('P65D')));
}
return null;
}
} }

View File

@ -43,7 +43,7 @@ msgstr ""
#: assets/components/LoginForm.tsx:58 #: assets/components/LoginForm.tsx:58
#: assets/components/RegisterForm.tsx:39 #: assets/components/RegisterForm.tsx:39
#: assets/components/RegisterForm.tsx:47 #: assets/components/RegisterForm.tsx:47
#: assets/components/search/DomainSearchBar.tsx:25 #: assets/components/search/DomainSearchBar.tsx:28
#: assets/components/tracking/connector/ConnectorForm.tsx:45 #: assets/components/tracking/connector/ConnectorForm.tsx:45
#: assets/components/tracking/connector/ConnectorForm.tsx:72 #: assets/components/tracking/connector/ConnectorForm.tsx:72
#: assets/components/tracking/connector/ConnectorForm.tsx:80 #: assets/components/tracking/connector/ConnectorForm.tsx:80
@ -147,7 +147,7 @@ msgstr ""
msgid "Entities" msgid "Entities"
msgstr "" msgstr ""
#: assets/components/search/DomainSearchBar.tsx:28 #: assets/components/search/DomainSearchBar.tsx:31
#: assets/components/tracking/watchlist/WatchlistForm.tsx:128 #: assets/components/tracking/watchlist/WatchlistForm.tsx:128
msgid "This domain name does not appear to be valid" msgid "This domain name does not appear to be valid"
msgstr "" msgstr ""
@ -161,7 +161,7 @@ msgid "Search"
msgstr "" msgstr ""
#: assets/components/Sider.tsx:41 #: assets/components/Sider.tsx:41
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:117 #: assets/components/tracking/watchlist/TrackedDomainTable.tsx:125
msgid "Domain" msgid "Domain"
msgstr "" msgstr ""
@ -425,37 +425,46 @@ msgid ""
"for registration again" "for registration again"
msgstr "" msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:123 #: assets/components/tracking/watchlist/TrackedDomainTable.tsx:101
msgid "Estimated number of days until release"
msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:104
#, javascript-format
msgid "J ${ d.expiresInDays }"
msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:131
msgid "Options" msgid "Options"
msgstr "" msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:128 #: assets/components/tracking/watchlist/TrackedDomainTable.tsx:136
msgid "Expiration date" msgid "Expiration date"
msgstr "" msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:141 #: assets/components/tracking/watchlist/TrackedDomainTable.tsx:149
msgid "Updated at" msgid "Updated at"
msgstr "" msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:148 #: assets/components/tracking/watchlist/TrackedDomainTable.tsx:156
msgid "Status" msgid "Status"
msgstr "" msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:168 #: assets/components/tracking/watchlist/TrackedDomainTable.tsx:176
msgid "No tracked domain names were found, please create your first Watchlist" msgid "No tracked domain names were found, please create your first Watchlist"
msgstr "" msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:177 #: assets/components/tracking/watchlist/TrackedDomainTable.tsx:185
msgid "" msgid ""
"Please note that this table does not include domain names marked as expired " "Please note that this table does not include domain names marked as expired "
"or those with an unknown expiration date" "or those with an unknown expiration date"
msgstr "" msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:182 #: assets/components/tracking/watchlist/TrackedDomainTable.tsx:190
msgid "At least one domain name you are tracking requires special attention" msgid "At least one domain name you are tracking requires special attention"
msgstr "" msgstr ""
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:188 #: assets/components/tracking/watchlist/TrackedDomainTable.tsx:196
msgid "The domain names below are subject to special monitoring" msgid "The domain names below are subject to special monitoring"
msgstr "" msgstr ""
@ -554,11 +563,11 @@ msgstr ""
msgid "Sorry, the page you visited does not exist." msgid "Sorry, the page you visited does not exist."
msgstr "" msgstr ""
#: assets/pages/search/DomainSearchPage.tsx:30 #: assets/pages/search/DomainSearchPage.tsx:32
msgid "Found !" msgid "Found !"
msgstr "" msgstr ""
#: assets/pages/search/DomainSearchPage.tsx:53 #: assets/pages/search/DomainSearchPage.tsx:55
msgid "" msgid ""
"Although the domain exists in my database, it has been deleted from the " "Although the domain exists in my database, it has been deleted from the "
"WHOIS by its registrar." "WHOIS by its registrar."