chore: rename WatchList to Watchlist

This commit is contained in:
Maël Gangloff
2025-10-25 17:26:56 +02:00
parent ff90477695
commit 5243b3c2dd
32 changed files with 278 additions and 199 deletions

View File

@@ -3,12 +3,12 @@
namespace App\MessageHandler;
use App\Entity\Domain;
use App\Entity\WatchList;
use App\Entity\Watchlist;
use App\Message\OrderDomain;
use App\Notifier\DomainOrderErrorNotification;
use App\Notifier\DomainOrderNotification;
use App\Repository\DomainRepository;
use App\Repository\WatchListRepository;
use App\Repository\WatchlistRepository;
use App\Service\ChatNotificationService;
use App\Service\InfluxdbService;
use App\Service\Provider\AbstractProvider;
@@ -31,7 +31,7 @@ final readonly class OrderDomainHandler
public function __construct(
string $mailerSenderEmail,
string $mailerSenderName,
private WatchListRepository $watchListRepository,
private WatchlistRepository $watchlistRepository,
private DomainRepository $domainRepository,
private KernelInterface $kernel,
private MailerInterface $mailer,
@@ -54,12 +54,12 @@ final readonly class OrderDomainHandler
*/
public function __invoke(OrderDomain $message): void
{
/** @var WatchList $watchList */
$watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]);
/** @var Watchlist $watchlist */
$watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]);
/** @var Domain $domain */
$domain = $this->domainRepository->findOneBy(['ldhName' => $message->ldhName]);
$connector = $watchList->getConnector();
$connector = $watchlist->getConnector();
/*
* We make sure that the domain name is marked absent from WHOIS in the database before continuing.
@@ -72,7 +72,7 @@ final readonly class OrderDomainHandler
}
$this->logger->notice('Watchlist is linked to a connector : a purchase attempt will be made for this domain name', [
'watchlist' => $message->watchListToken,
'watchlist' => $message->watchlistToken,
'connector' => $connector->getId(),
'ldhName' => $message->ldhName,
'provider' => $connector->getProvider()->value,
@@ -101,7 +101,7 @@ final readonly class OrderDomainHandler
* If the purchase was successful, the statistics are updated and a success message is sent to the user.
*/
$this->logger->notice('Watchlist is linked to connector : a purchase was successfully made for this domain name', [
'watchlist' => $message->watchListToken,
'watchlist' => $message->watchlistToken,
'connector' => $connector->getId(),
'ldhName' => $message->ldhName,
'provider' => $connector->getProvider()->value,
@@ -112,15 +112,15 @@ final readonly class OrderDomainHandler
$this->influxdbService->addDomainOrderPoint($connector, $domain, true);
}
$notification = (new DomainOrderNotification($this->sender, $domain, $connector));
$this->mailer->send($notification->asEmailMessage(new Recipient($watchList->getUser()->getEmail()))->getMessage());
$this->chatNotificationService->sendChatNotification($watchList, $notification);
$this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage());
$this->chatNotificationService->sendChatNotification($watchlist, $notification);
} catch (\Throwable $exception) {
/*
* The purchase was not successful (for several possible reasons that we have not determined).
* The user is informed and the exception is raised, which may allow you to try again.
*/
$this->logger->warning('Unable to complete purchase : an error message is sent to the user', [
'watchlist' => $message->watchListToken,
'watchlist' => $message->watchlistToken,
'connector' => $connector->getId(),
'ldhName' => $message->ldhName,
'provider' => $connector->getProvider()->value,
@@ -131,8 +131,8 @@ final readonly class OrderDomainHandler
$this->influxdbService->addDomainOrderPoint($connector, $domain, false);
}
$notification = (new DomainOrderErrorNotification($this->sender, $domain));
$this->mailer->send($notification->asEmailMessage(new Recipient($watchList->getUser()->getEmail()))->getMessage());
$this->chatNotificationService->sendChatNotification($watchList, $notification);
$this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage());
$this->chatNotificationService->sendChatNotification($watchlist, $notification);
throw $exception;
}

View File

@@ -2,20 +2,20 @@
namespace App\MessageHandler;
use App\Entity\WatchList;
use App\Message\ProcessWatchListsTrigger;
use App\Entity\Watchlist;
use App\Message\ProcessWatchlistTrigger;
use App\Message\UpdateDomainsFromWatchlist;
use App\Repository\WatchListRepository;
use App\Repository\WatchlistRepository;
use Random\Randomizer;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Messenger\Exception\ExceptionInterface;
use Symfony\Component\Messenger\MessageBusInterface;
#[AsMessageHandler]
final readonly class ProcessWatchListsTriggerHandler
final readonly class ProcessWatchlistTriggerHandler
{
public function __construct(
private WatchListRepository $watchListRepository,
private WatchlistRepository $watchlistRepository,
private MessageBusInterface $bus,
) {
}
@@ -23,7 +23,7 @@ final readonly class ProcessWatchListsTriggerHandler
/**
* @throws ExceptionInterface
*/
public function __invoke(ProcessWatchListsTrigger $message): void
public function __invoke(ProcessWatchlistTrigger $message): void
{
/*
* We shuffle the watch lists to process them in an order that we consider random.
@@ -31,11 +31,11 @@ final readonly class ProcessWatchListsTriggerHandler
*/
$randomizer = new Randomizer();
$watchLists = $randomizer->shuffleArray($this->watchListRepository->findAll());
$watchlists = $randomizer->shuffleArray($this->watchlistRepository->findAll());
/** @var WatchList $watchList */
foreach ($watchLists as $watchList) {
$this->bus->dispatch(new UpdateDomainsFromWatchlist($watchList->getToken()));
/** @var Watchlist $watchlist */
foreach ($watchlists as $watchlist) {
$this->bus->dispatch(new UpdateDomainsFromWatchlist($watchlist->getToken()));
}
}
}

View File

@@ -5,14 +5,14 @@ namespace App\MessageHandler;
use App\Entity\Domain;
use App\Entity\DomainEvent;
use App\Entity\DomainStatus;
use App\Entity\WatchList;
use App\Entity\Watchlist;
use App\Message\SendDomainEventNotif;
use App\Notifier\DomainStatusUpdateNotification;
use App\Notifier\DomainUpdateNotification;
use App\Repository\DomainEventRepository;
use App\Repository\DomainRepository;
use App\Repository\DomainStatusRepository;
use App\Repository\WatchListRepository;
use App\Repository\WatchlistRepository;
use App\Service\ChatNotificationService;
use App\Service\InfluxdbService;
use App\Service\StatService;
@@ -36,7 +36,7 @@ final readonly class SendDomainEventNotifHandler
private MailerInterface $mailer,
private StatService $statService,
private DomainRepository $domainRepository,
private WatchListRepository $watchListRepository,
private WatchlistRepository $watchlistRepository,
private ChatNotificationService $chatNotificationService,
#[Autowire(param: 'influxdb_enabled')]
private bool $influxdbEnabled,
@@ -53,11 +53,11 @@ final readonly class SendDomainEventNotifHandler
*/
public function __invoke(SendDomainEventNotif $message): void
{
/** @var WatchList $watchList */
$watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]);
/** @var Watchlist $watchlist */
$watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]);
/** @var Domain $domain */
$domain = $this->domainRepository->findOneBy(['ldhName' => $message->ldhName]);
$recipient = new Recipient($watchList->getUser()->getEmail());
$recipient = new Recipient($watchlist->getUser()->getEmail());
/*
* For each new event whose date is after the domain name update date (before the current domain name update)
@@ -67,7 +67,7 @@ final readonly class SendDomainEventNotifHandler
$newEvents = $this->domainEventRepository->findNewDomainEvents($domain, $message->updatedAt);
foreach ($newEvents as $event) {
if (!in_array($event->getAction(), $watchList->getTrackedEvents())) {
if (!in_array($event->getAction(), $watchlist->getTrackedEvents())) {
continue;
}
@@ -76,7 +76,7 @@ final readonly class SendDomainEventNotifHandler
$this->logger->info('New action has been detected on this domain name : an email is sent to user', [
'event' => $event->getAction(),
'ldhName' => $message->ldhName,
'username' => $watchList->getUser()->getUserIdentifier(),
'username' => $watchlist->getUser()->getUserIdentifier(),
]);
$this->mailer->send($notification->asEmailMessage($recipient)->getMessage());
@@ -85,15 +85,15 @@ final readonly class SendDomainEventNotifHandler
$this->influxdbService->addDomainNotificationPoint($domain, 'email', true);
}
$webhookDsn = $watchList->getWebhookDsn();
$webhookDsn = $watchlist->getWebhookDsn();
if (null !== $webhookDsn && 0 !== count($webhookDsn)) {
$this->logger->info('New action has been detected on this domain name : a notification is sent to user', [
'event' => $event->getAction(),
'ldhName' => $message->ldhName,
'username' => $watchList->getUser()->getUserIdentifier(),
'username' => $watchlist->getUser()->getUserIdentifier(),
]);
$this->chatNotificationService->sendChatNotification($watchList, $notification);
$this->chatNotificationService->sendChatNotification($watchlist, $notification);
if ($this->influxdbEnabled) {
$this->influxdbService->addDomainNotificationPoint($domain, 'chat', true);
}
@@ -106,7 +106,7 @@ final readonly class SendDomainEventNotifHandler
$domainStatus = $this->domainStatusRepository->findNewDomainStatus($domain, $message->updatedAt);
if (null !== $domainStatus && count(array_intersect(
$watchList->getTrackedEppStatus(),
$watchlist->getTrackedEppStatus(),
[...$domainStatus->getAddStatus(), ...$domainStatus->getDeleteStatus()]
))) {
$notification = new DomainStatusUpdateNotification($this->sender, $domain, $domainStatus);
@@ -116,7 +116,7 @@ final readonly class SendDomainEventNotifHandler
'deleteStatus' => $domainStatus->getDeleteStatus(),
'status' => $domain->getStatus(),
'ldhName' => $message->ldhName,
'username' => $watchList->getUser()->getUserIdentifier(),
'username' => $watchlist->getUser()->getUserIdentifier(),
]);
$this->mailer->send($notification->asEmailMessage($recipient)->getMessage());
@@ -125,17 +125,17 @@ final readonly class SendDomainEventNotifHandler
$this->influxdbService->addDomainNotificationPoint($domain, 'email', true);
}
$webhookDsn = $watchList->getWebhookDsn();
$webhookDsn = $watchlist->getWebhookDsn();
if (null !== $webhookDsn && 0 !== count($webhookDsn)) {
$this->logger->info('New domain status has been detected on this domain name : a notification is sent to user', [
'addStatus' => $domainStatus->getAddStatus(),
'deleteStatus' => $domainStatus->getDeleteStatus(),
'status' => $domain->getStatus(),
'ldhName' => $message->ldhName,
'username' => $watchList->getUser()->getUserIdentifier(),
'username' => $watchlist->getUser()->getUserIdentifier(),
]);
$this->chatNotificationService->sendChatNotification($watchList, $notification);
$this->chatNotificationService->sendChatNotification($watchlist, $notification);
if ($this->influxdbEnabled) {
$this->influxdbService->addDomainNotificationPoint($domain, 'chat', true);

View File

@@ -3,7 +3,7 @@
namespace App\MessageHandler;
use App\Entity\Domain;
use App\Entity\WatchList;
use App\Entity\Watchlist;
use App\Exception\DomainNotFoundException;
use App\Exception\TldNotSupportedException;
use App\Exception\UnknownRdapServerException;
@@ -12,7 +12,7 @@ use App\Message\SendDomainEventNotif;
use App\Message\UpdateDomainsFromWatchlist;
use App\Notifier\DomainDeletedNotification;
use App\Repository\DomainRepository;
use App\Repository\WatchListRepository;
use App\Repository\WatchlistRepository;
use App\Service\ChatNotificationService;
use App\Service\Provider\AbstractProvider;
use App\Service\Provider\CheckDomainProviderInterface;
@@ -38,7 +38,7 @@ final readonly class UpdateDomainsFromWatchlistHandler
string $mailerSenderEmail,
string $mailerSenderName,
private MessageBusInterface $bus,
private WatchListRepository $watchListRepository,
private WatchlistRepository $watchlistRepository,
private LoggerInterface $logger,
#[Autowire(service: 'service_container')]
private ContainerInterface $locator,
@@ -52,29 +52,29 @@ final readonly class UpdateDomainsFromWatchlistHandler
*/
public function __invoke(UpdateDomainsFromWatchlist $message): void
{
/** @var WatchList $watchList */
$watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]);
/** @var Watchlist $watchlist */
$watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]);
$this->logger->debug('Domain names listed in the Watchlist will be updated', [
'watchlist' => $message->watchListToken,
'watchlist' => $message->watchlistToken,
]);
/** @var AbstractProvider $connectorProvider */
$connectorProvider = $this->getConnectorProvider($watchList);
$connectorProvider = $this->getConnectorProvider($watchlist);
if ($connectorProvider instanceof CheckDomainProviderInterface) {
$this->logger->debug('Watchlist is linked to a connector', [
'watchlist' => $watchList->getToken(),
'connector' => $watchList->getConnector()->getId(),
'watchlist' => $watchlist->getToken(),
'connector' => $watchlist->getConnector()->getId(),
]);
$domainList = array_unique(array_map(fn (Domain $d) => $d->getLdhName(), $watchList->getDomains()->toArray()));
$domainList = array_unique(array_map(fn (Domain $d) => $d->getLdhName(), $watchlist->getDomains()->toArray()));
try {
$checkedDomains = $connectorProvider->checkDomains(...$domainList);
} catch (\Throwable $exception) {
$this->logger->warning('Unable to check domain names availability with this connector', [
'connector' => $watchList->getConnector()->getId(),
'connector' => $watchlist->getConnector()->getId(),
'ldhName' => $domainList,
]);
@@ -82,7 +82,7 @@ final readonly class UpdateDomainsFromWatchlistHandler
}
foreach ($checkedDomains as $domain) {
$this->bus->dispatch(new OrderDomain($watchList->getToken(), $domain));
$this->bus->dispatch(new OrderDomain($watchlist->getToken(), $domain));
}
return;
@@ -96,7 +96,7 @@ final readonly class UpdateDomainsFromWatchlistHandler
*/
/** @var Domain $domain */
foreach ($watchList->getDomains()->filter(fn ($domain) => $this->RDAPService->isToBeUpdated($domain, false, null !== $watchList->getConnector())) as $domain
foreach ($watchlist->getDomains()->filter(fn ($domain) => $this->RDAPService->isToBeUpdated($domain, false, null !== $watchlist->getConnector())) as $domain
) {
$updatedAt = $domain->getUpdatedAt();
$deleted = $domain->getDeleted();
@@ -107,22 +107,22 @@ final readonly class UpdateDomainsFromWatchlistHandler
* We send messages that correspond to the sending of notifications that will not be processed here.
*/
$this->RDAPService->registerDomain($domain->getLdhName());
$this->bus->dispatch(new SendDomainEventNotif($watchList->getToken(), $domain->getLdhName(), $updatedAt));
$this->bus->dispatch(new SendDomainEventNotif($watchlist->getToken(), $domain->getLdhName(), $updatedAt));
} catch (DomainNotFoundException) {
$newDomain = $this->domainRepository->findOneBy(['ldhName' => $domain->getLdhName()]);
if (!$deleted && null !== $newDomain && $newDomain->getDeleted()) {
$notification = new DomainDeletedNotification($this->sender, $domain);
$this->mailer->send($notification->asEmailMessage(new Recipient($watchList->getUser()->getEmail()))->getMessage());
$this->chatNotificationService->sendChatNotification($watchList, $notification);
$this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage());
$this->chatNotificationService->sendChatNotification($watchlist, $notification);
}
if ($watchList->getConnector()) {
if ($watchlist->getConnector()) {
/*
* If the domain name no longer appears in the WHOIS AND a connector is associated with this Watchlist,
* this connector is used to purchase the domain name.
*/
$this->bus->dispatch(new OrderDomain($watchList->getToken(), $domain->getLdhName()));
$this->bus->dispatch(new OrderDomain($watchlist->getToken(), $domain->getLdhName()));
}
} catch (TldNotSupportedException|UnknownRdapServerException) {
/*
@@ -132,9 +132,9 @@ final readonly class UpdateDomainsFromWatchlistHandler
}
}
private function getConnectorProvider(WatchList $watchList): ?object
private function getConnectorProvider(Watchlist $watchlist): ?object
{
$connector = $watchList->getConnector();
$connector = $watchlist->getConnector();
if (null === $connector || null === $connector->getProvider()) {
return null;
}