sender = new Address($mailerSenderEmail, $mailerSenderName); } /** * @throws TransportExceptionInterface * @throws \Symfony\Component\Notifier\Exception\TransportExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws OptimisticLockException * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface * @throws UnsupportedDsnSchemeException * @throws ServerExceptionInterface * @throws MalformedDomainException * @throws ExceptionInterface * @throws \Exception */ public function __invoke(UpdateDomain $message): void { $domain = $this->domainRepository->findOneBy(['ldhName' => $message->ldhName]); if (null === $domain) { $this->RDAPService->registerDomain($message->ldhName); return; } /** @var ?RdapServer $rdapServer */ $rdapServer = $domain->getTld()->getRdapServers()->first(); if (null === $rdapServer) { $this->logger->warning('No RDAP server for this domain name', [ 'ldhName' => $domain->getLdhName(), ]); return; } $watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]); if (null === $watchlist) { /** @var Watchlist $wl */ foreach ($domain->getWatchlists()->getIterator() as $wl) { $this->bus->dispatch(new UpdateDomain($message->ldhName, $wl->getToken())); } return; } if (!$this->RDAPService->isToBeUpdated($domain, false, null !== $watchlist->getConnector())) { $this->logger->debug('The domain name is already present in the database and does not need to be updated at this time', [ 'ldhName' => $domain->getLdhName(), ]); return; } $updatedAt = $domain->getUpdatedAt(); $deleted = $domain->getDeleted(); try { /* * Domain name update * We send messages that correspond to the sending of notifications that will not be processed here. */ $this->RDAPService->registerDomain($domain->getLdhName()); /** @var Watchlist $wl */ foreach ($domain->getWatchlists()->getIterator() as $wl) { $this->bus->dispatch(new DetectDomainChange($wl->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); } 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())); } } catch (TldNotSupportedException|UnknownRdapServerException) { /* * In this case, the domain name can no longer be updated. Unfortunately, there is nothing more that can be done. */ } } }