Skip to content

Commit

Permalink
feat: shuffle watchlists when a domain is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Aug 4, 2024
1 parent 8e11626 commit c89cd6c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Controller/DomainRefreshController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;
Expand Down Expand Up @@ -74,8 +75,11 @@ public function __invoke(string $ldhName, KernelInterface $kernel): ?Domain
$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));
}

Expand Down

0 comments on commit c89cd6c

Please sign in to comment.