mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
refactor: change log level and add exceptions
This commit is contained in:
@@ -10,8 +10,8 @@ use App\Notifier\DomainOrderNotification;
|
||||
use App\Repository\DomainRepository;
|
||||
use App\Repository\WatchListRepository;
|
||||
use App\Service\ChatNotificationService;
|
||||
use App\Service\Connector\AbstractProvider;
|
||||
use App\Service\InfluxdbService;
|
||||
use App\Service\Provider\AbstractProvider;
|
||||
use App\Service\StatService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
@@ -118,7 +118,7 @@ final readonly class OrderDomainHandler
|
||||
* 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 user', [
|
||||
$this->logger->warning('Unable to complete purchase : an error message is sent to the user', [
|
||||
'watchlist' => $message->watchListToken,
|
||||
'connector' => $connector->getId(),
|
||||
'ldhName' => $message->ldhName,
|
||||
|
||||
@@ -73,22 +73,29 @@ final readonly class SendDomainEventNotifHandler
|
||||
|
||||
/** @var WatchListTrigger $watchListTrigger */
|
||||
foreach ($watchListTriggers->getIterator() as $watchListTrigger) {
|
||||
$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(),
|
||||
]);
|
||||
|
||||
$recipient = new Recipient($watchList->getUser()->getEmail());
|
||||
$notification = new DomainUpdateNotification($this->sender, $event);
|
||||
|
||||
if (TriggerAction::SendEmail == $watchListTrigger->getAction()) {
|
||||
$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(),
|
||||
]);
|
||||
|
||||
$this->mailer->send($notification->asEmailMessage($recipient)->getMessage());
|
||||
} elseif (TriggerAction::SendChat == $watchListTrigger->getAction()) {
|
||||
$webhookDsn = $watchList->getWebhookDsn();
|
||||
if (null === $webhookDsn || 0 === count($webhookDsn)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$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(),
|
||||
]);
|
||||
|
||||
$this->chatNotificationService->sendChatNotification($watchList, $notification);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ use App\Notifier\DomainDeletedNotification;
|
||||
use App\Repository\DomainRepository;
|
||||
use App\Repository\WatchListRepository;
|
||||
use App\Service\ChatNotificationService;
|
||||
use App\Service\Connector\AbstractProvider;
|
||||
use App\Service\Connector\CheckDomainProviderInterface;
|
||||
use App\Service\Provider\AbstractProvider;
|
||||
use App\Service\Provider\CheckDomainProviderInterface;
|
||||
use App\Service\RDAPService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
@@ -55,7 +55,7 @@ final readonly class UpdateDomainsFromWatchlistHandler
|
||||
/** @var WatchList $watchList */
|
||||
$watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]);
|
||||
|
||||
$this->logger->info('Domain names listed in the Watchlist will be updated', [
|
||||
$this->logger->debug('Domain names listed in the Watchlist will be updated', [
|
||||
'watchlist' => $message->watchListToken,
|
||||
]);
|
||||
|
||||
@@ -63,18 +63,19 @@ final readonly class UpdateDomainsFromWatchlistHandler
|
||||
$connectorProvider = $this->getConnectorProvider($watchList);
|
||||
|
||||
if ($connectorProvider instanceof CheckDomainProviderInterface) {
|
||||
$this->logger->notice('Watchlist is linked to a connector', [
|
||||
$this->logger->debug('Watchlist is linked to a connector', [
|
||||
'watchlist' => $watchList->getToken(),
|
||||
'connector' => $watchList->getConnector()->getId(),
|
||||
]);
|
||||
|
||||
$domainList = array_unique(array_map(fn (Domain $d) => $d->getLdhName(), $watchList->getDomains()->toArray()));
|
||||
|
||||
try {
|
||||
$checkedDomains = $connectorProvider->checkDomains(
|
||||
...array_unique(array_map(fn (Domain $d) => $d->getLdhName(), $watchList->getDomains()->toArray()))
|
||||
);
|
||||
$checkedDomains = $connectorProvider->checkDomains(...$domainList);
|
||||
} catch (\Throwable $exception) {
|
||||
$this->logger->warning('Unable to check domain names availability with this connector', [
|
||||
'connector' => $watchList->getConnector()->getId(),
|
||||
'ldhName' => $domainList,
|
||||
]);
|
||||
|
||||
throw $exception;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\MessageHandler;
|
||||
use App\Message\ValidateConnectorCredentials;
|
||||
use App\Notifier\ValidateConnectorCredentialsErrorNotification;
|
||||
use App\Repository\ConnectorRepository;
|
||||
use App\Service\Connector\AbstractProvider;
|
||||
use App\Service\Provider\AbstractProvider;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||
|
||||
Reference in New Issue
Block a user