From c89cd6ce8b0c533916fa18723188e5f35d5661d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Sun, 4 Aug 2024 21:26:32 +0200 Subject: [PATCH] feat: shuffle watchlists when a domain is updated --- src/Controller/DomainRefreshController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Controller/DomainRefreshController.php b/src/Controller/DomainRefreshController.php index 07542a4..4abf86e 100644 --- a/src/Controller/DomainRefreshController.php +++ b/src/Controller/DomainRefreshController.php @@ -8,6 +8,7 @@ use App\Message\ProcessDomainTrigger; use App\Repository\DomainRepository; use App\Service\RDAPService; use Psr\Log\LoggerInterface; +use Random\Randomizer; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; use Symfony\Component\HttpKernel\KernelInterface; @@ -74,8 +75,11 @@ class DomainRefreshController extends AbstractController $updatedAt = null === $domain ? new \DateTimeImmutable('now') : $domain->getUpdatedAt(); $domain = $this->RDAPService->registerDomain($idnDomain); + $randomizer = new Randomizer(); + $watchLists = $randomizer->shuffleArray($domain->getWatchLists()->toArray()); + /** @var WatchList $watchList */ - foreach ($domain->getWatchLists()->getIterator() as $watchList) { + foreach ($watchLists as $watchList) { $this->bus->dispatch(new ProcessDomainTrigger($watchList->getToken(), $domain->getLdhName(), $updatedAt)); }