sender = new Address($mailerSenderEmail, $mailerSenderName); } /** * @throws ExceptionInterface * @throws TransportExceptionInterface * @throws ClientExceptionInterface * @throws DecodingExceptionInterface * @throws RedirectionExceptionInterface * @throws ServerExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface * @throws \Throwable */ public function __invoke(UpdateDomainsFromWatchlist $message): void { /** @var WatchList $watchList */ $watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]); $this->logger->info('Domain names from Watchlist {token} will be processed.', [ 'token' => $message->watchListToken, ]); /** @var Domain $domain */ foreach ($watchList->getDomains() ->filter(fn ($domain) => $domain->getUpdatedAt() ->diff(new \DateTimeImmutable())->days >= 7 || ( ($domain->getUpdatedAt() ->diff(new \DateTimeImmutable())->h * 60 + $domain->getUpdatedAt() ->diff(new \DateTimeImmutable())->i) >= 50 && $this->RDAPService::isToBeWatchClosely($domain) ) || (count(array_intersect($domain->getStatus(), ['auto renew period', 'client hold', 'server hold'])) > 0 && $domain->getUpdatedAt()->diff(new \DateTimeImmutable())->days >= 1 ) ) as $domain ) { $updatedAt = $domain->getUpdatedAt(); try { $this->RDAPService->registerDomain($domain->getLdhName()); $this->bus->dispatch(new SendDomainEventNotif($watchList->getToken(), $domain->getLdhName(), $updatedAt)); } catch (NotFoundHttpException) { if (null !== $watchList->getConnector()) { $this->bus->dispatch(new OrderDomain($watchList->getToken(), $domain->getLdhName(), $updatedAt)); } } catch (\Throwable $e) { $this->logger->error('An update error email is sent to user {username}.', [ 'username' => $watchList->getUser()->getUserIdentifier(), 'error' => $e, ]); $email = (new DomainUpdateErrorNotification($this->sender, $domain)) ->asEmailMessage(new Recipient($watchList->getUser()->getEmail())); $this->mailer->send($email->getMessage()); throw $e; } } } }