mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
fix: prevent domainPurchase duplicates
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Entity\Watchlist;
|
|||||||
use App\Message\OrderDomain;
|
use App\Message\OrderDomain;
|
||||||
use App\Notifier\DomainOrderErrorNotification;
|
use App\Notifier\DomainOrderErrorNotification;
|
||||||
use App\Notifier\DomainOrderNotification;
|
use App\Notifier\DomainOrderNotification;
|
||||||
|
use App\Repository\DomainPurchaseRepository;
|
||||||
use App\Repository\DomainRepository;
|
use App\Repository\DomainRepository;
|
||||||
use App\Repository\WatchlistRepository;
|
use App\Repository\WatchlistRepository;
|
||||||
use App\Service\ChatNotificationService;
|
use App\Service\ChatNotificationService;
|
||||||
@@ -42,7 +43,7 @@ final readonly class OrderDomainHandler
|
|||||||
#[Autowire(service: 'service_container')]
|
#[Autowire(service: 'service_container')]
|
||||||
private ContainerInterface $locator,
|
private ContainerInterface $locator,
|
||||||
#[Autowire(param: 'influxdb_enabled')]
|
#[Autowire(param: 'influxdb_enabled')]
|
||||||
private bool $influxdbEnabled, private EntityManagerInterface $em,
|
private bool $influxdbEnabled, private EntityManagerInterface $em, private DomainPurchaseRepository $domainPurchaseRepository,
|
||||||
) {
|
) {
|
||||||
$this->sender = new Address($mailerSenderEmail, $mailerSenderName);
|
$this->sender = new Address($mailerSenderEmail, $mailerSenderName);
|
||||||
}
|
}
|
||||||
@@ -142,15 +143,24 @@ final readonly class OrderDomainHandler
|
|||||||
$this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage());
|
$this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage());
|
||||||
$this->chatNotificationService->sendChatNotification($watchlist, $notification);
|
$this->chatNotificationService->sendChatNotification($watchlist, $notification);
|
||||||
|
|
||||||
$this->em->persist((new DomainPurchase())
|
$domainPurchase = $this->domainPurchaseRepository->findOneBy([
|
||||||
->setDomain($domain)
|
'domain' => $domain,
|
||||||
->setConnector($connector)
|
'connector' => $connector,
|
||||||
->setConnectorProvider($connector->getProvider())
|
'domainOrderedAt' => null,
|
||||||
->setDomainOrderedAt(null)
|
'domainUpdatedAt' => $message->updatedAt,
|
||||||
->setUser($watchlist->getUser())
|
'user' => $watchlist->getUser(),
|
||||||
->setDomainDeletedAt($domain->getUpdatedAt())
|
]);
|
||||||
->setDomainUpdatedAt($message->updatedAt));
|
if (null === $domainPurchase) {
|
||||||
$this->em->flush();
|
$this->em->persist((new DomainPurchase())
|
||||||
|
->setDomain($domain)
|
||||||
|
->setConnector($connector)
|
||||||
|
->setConnectorProvider($connector->getProvider())
|
||||||
|
->setDomainOrderedAt(null)
|
||||||
|
->setUser($watchlist->getUser())
|
||||||
|
->setDomainDeletedAt($domain->getUpdatedAt())
|
||||||
|
->setDomainUpdatedAt($message->updatedAt));
|
||||||
|
$this->em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user