diff --git a/assets/components/tracking/watchlist/UpdateWatchlistButton.tsx b/assets/components/tracking/watchlist/UpdateWatchlistButton.tsx index 419b06b..215388d 100644 --- a/assets/components/tracking/watchlist/UpdateWatchlistButton.tsx +++ b/assets/components/tracking/watchlist/UpdateWatchlistButton.tsx @@ -63,7 +63,7 @@ export function UpdateWatchlistButton({watchlist, onUpdateWatchlist, connectors} }} connectors={connectors} isCreation={false} - watchList={watchlist} + watchlist={watchlist} /> diff --git a/assets/components/tracking/watchlist/WatchlistForm.tsx b/assets/components/tracking/watchlist/WatchlistForm.tsx index a8ffc01..dc2c2f8 100644 --- a/assets/components/tracking/watchlist/WatchlistForm.tsx +++ b/assets/components/tracking/watchlist/WatchlistForm.tsx @@ -33,7 +33,7 @@ export function WatchlistForm({form, connectors, onFinish, isCreation}: { connectors: Array onFinish: (values: { domains: string[], trackedEvents: string[], trackedEppStatus: string[], token: string }) => void isCreation: boolean, - watchList?: Watchlist, + watchlist?: Watchlist, }) { const rdapEventNameTranslated = rdapEventNameTranslation() const rdapEventDetailTranslated = rdapEventDetailTranslation() diff --git a/config/packages/messenger.yaml b/config/packages/messenger.yaml index 8a72323..ca8a7b3 100644 --- a/config/packages/messenger.yaml +++ b/config/packages/messenger.yaml @@ -23,7 +23,7 @@ framework: Symfony\Component\Notifier\Message\SmsMessage: async App\Message\OrderDomain: async - App\Message\ProcessWatchListsTrigger: async + App\Message\ProcessWatchlistTrigger: async App\Message\SendDomainEventNotif: async App\Message\UpdateDomainsFromWatchlist: async App\Message\UpdateRdapServers: async diff --git a/migrations/Version20251025152900.php b/migrations/Version20251025152900.php new file mode 100644 index 0000000..63112dc --- /dev/null +++ b/migrations/Version20251025152900.php @@ -0,0 +1,79 @@ +addSql('ALTER TABLE watch_lists_domains DROP CONSTRAINT fk_f693e1d0d52d7aa6'); + $this->addSql('ALTER TABLE watch_list DROP CONSTRAINT fk_152b584b4d085745'); + $this->addSql('ALTER TABLE watch_list DROP CONSTRAINT fk_152b584ba76ed395'); + + $this->addSql('ALTER TABLE watch_list RENAME TO watchlist'); + $this->addSql('ALTER INDEX idx_152b584ba76ed395 RENAME TO IDX_340388D3A76ED395'); + $this->addSql('ALTER INDEX idx_152b584b4d085745 RENAME TO IDX_340388D34D085745'); + + $this->addSql('ALTER TABLE watchlist ADD CONSTRAINT FK_340388D3A76ED395 FOREIGN KEY (user_id) REFERENCES "user" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE watchlist ADD CONSTRAINT FK_340388D34D085745 FOREIGN KEY (connector_id) REFERENCES connector (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + + $this->addSql('ALTER TABLE watch_lists_domains ADD CONSTRAINT FK_F693E1D0D52D7AA6 FOREIGN KEY (watch_list_token) REFERENCES watchlist (token) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + + $this->addSql('ALTER TABLE watch_lists_domains DROP CONSTRAINT fk_f693e1d0af923913'); + $this->addSql('ALTER TABLE watch_lists_domains DROP CONSTRAINT fk_f693e1d0d52d7aa6'); + + $this->addSql('ALTER TABLE watch_lists_domains RENAME TO watchlist_domains'); + $this->addSql('ALTER INDEX idx_f693e1d0af923913 RENAME TO IDX_196DE762AF923913'); + $this->addSql('ALTER INDEX idx_f693e1d0d52d7aa6 RENAME TO IDX_196DE762F1E43AD7'); + + $this->addSql('ALTER TABLE watchlist_domains RENAME COLUMN watch_list_token TO watchlist_token'); + + $this->addSql('COMMENT ON COLUMN watchlist_domains.watchlist_token IS \'(DC2Type:uuid)\''); + + $this->addSql('ALTER TABLE watchlist_domains ADD CONSTRAINT FK_196DE762F1E43AD7 FOREIGN KEY (watchlist_token) REFERENCES watchlist (token) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE watchlist_domains ADD CONSTRAINT FK_196DE762AF923913 FOREIGN KEY (domain_ldh_name) REFERENCES domain (ldh_name) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE watch_lists_domains DROP CONSTRAINT FK_F693E1D0D52D7AA6'); + $this->addSql('ALTER TABLE watchlist DROP CONSTRAINT FK_340388D3A76ED395'); + $this->addSql('ALTER TABLE watchlist DROP CONSTRAINT FK_340388D34D085745'); + + $this->addSql('ALTER TABLE watchlist RENAME TO watch_list'); + $this->addSql('ALTER INDEX IDX_340388D3A76ED395 RENAME TO idx_152b584ba76ed395'); + $this->addSql('ALTER INDEX IDX_340388D34D085745 RENAME TO idx_152b584b4d085745'); + + $this->addSql('ALTER TABLE watch_list ADD CONSTRAINT fk_152b584ba76ed395 FOREIGN KEY (user_id) REFERENCES "user" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE watch_list ADD CONSTRAINT fk_152b584b4d085745 FOREIGN KEY (connector_id) REFERENCES connector (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + + $this->addSql('ALTER TABLE watch_lists_domains ADD CONSTRAINT fk_f693e1d0d52d7aa6 FOREIGN KEY (watch_list_token) REFERENCES watch_list (token) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + + $this->addSql('ALTER TABLE watchlist_domains DROP CONSTRAINT FK_196DE762F1E43AD7'); + $this->addSql('ALTER TABLE watchlist_domains DROP CONSTRAINT FK_196DE762AF923913'); + + $this->addSql('ALTER TABLE watchlist_domains RENAME COLUMN watchlist_token TO watch_list_token'); + + $this->addSql('ALTER TABLE watchlist_domains RENAME TO watch_lists_domains'); + $this->addSql('ALTER INDEX IDX_196DE762AF923913 RENAME TO idx_f693e1d0af923913'); + $this->addSql('ALTER INDEX IDX_196DE762F1E43AD7 RENAME TO idx_f693e1d0d52d7aa6'); + + $this->addSql('COMMENT ON COLUMN watch_lists_domains.watch_list_token IS \'(DC2Type:uuid)\''); + + $this->addSql('ALTER TABLE watch_lists_domains ADD CONSTRAINT fk_f693e1d0af923913 FOREIGN KEY (domain_ldh_name) REFERENCES domain (ldh_name) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE watch_lists_domains ADD CONSTRAINT fk_f693e1d0d52d7aa6 FOREIGN KEY (watch_list_token) REFERENCES watchlist (token) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } +} diff --git a/src/Command/ProcessWatchlistsCommand.php b/src/Command/ProcessWatchlistCommand.php similarity index 77% rename from src/Command/ProcessWatchlistsCommand.php rename to src/Command/ProcessWatchlistCommand.php index a5d4f41..1d4a84a 100644 --- a/src/Command/ProcessWatchlistsCommand.php +++ b/src/Command/ProcessWatchlistCommand.php @@ -2,7 +2,7 @@ namespace App\Command; -use App\Message\ProcessWatchListsTrigger; +use App\Message\ProcessWatchlistTrigger; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -12,10 +12,10 @@ use Symfony\Component\Messenger\Exception\ExceptionInterface; use Symfony\Component\Messenger\MessageBusInterface; #[AsCommand( - name: 'app:process-watchlists', - description: 'Process watchlists and send emails if necessary', + name: 'app:process-watchlist', + description: 'Process watchlist and send emails if necessary', )] -class ProcessWatchlistsCommand extends Command +class ProcessWatchlistCommand extends Command { public function __construct(private readonly MessageBusInterface $bus) { @@ -33,7 +33,7 @@ class ProcessWatchlistsCommand extends Command { $io = new SymfonyStyle($input, $output); - $this->bus->dispatch(new ProcessWatchListsTrigger()); + $this->bus->dispatch(new ProcessWatchlistTrigger()); $io->success('Watchlist processing triggered!'); diff --git a/src/Command/RegisterDomainCommand.php b/src/Command/RegisterDomainCommand.php index 98e5a88..7d4e281 100644 --- a/src/Command/RegisterDomainCommand.php +++ b/src/Command/RegisterDomainCommand.php @@ -2,7 +2,7 @@ namespace App\Command; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Message\SendDomainEventNotif; use App\Repository\DomainRepository; use App\Service\RDAPService; @@ -60,11 +60,11 @@ class RegisterDomainCommand extends Command if ($notif) { $randomizer = new Randomizer(); - $watchLists = $randomizer->shuffleArray($domain->getWatchLists()->toArray()); + $watchlists = $randomizer->shuffleArray($domain->getWatchlists()->toArray()); - /** @var WatchList $watchList */ - foreach ($watchLists as $watchList) { - $this->bus->dispatch(new SendDomainEventNotif($watchList->getToken(), $domain->getLdhName(), $updatedAt)); + /** @var Watchlist $watchlist */ + foreach ($watchlists as $watchlist) { + $this->bus->dispatch(new SendDomainEventNotif($watchlist->getToken(), $domain->getLdhName(), $updatedAt)); } } } catch (\Throwable $e) { diff --git a/src/Controller/StatisticsController.php b/src/Controller/StatisticsController.php index a751500..a1685ae 100644 --- a/src/Controller/StatisticsController.php +++ b/src/Controller/StatisticsController.php @@ -4,7 +4,7 @@ namespace App\Controller; use App\Entity\Statistics; use App\Repository\DomainRepository; -use App\Repository\WatchListRepository; +use App\Repository\WatchlistRepository; use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\InvalidArgumentException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -15,7 +15,7 @@ class StatisticsController extends AbstractController public function __construct( private readonly CacheItemPoolInterface $pool, private readonly DomainRepository $domainRepository, - private readonly WatchListRepository $watchListRepository, + private readonly WatchlistRepository $watchlistRepository, private readonly KernelInterface $kernel, ) { } @@ -34,7 +34,7 @@ class StatisticsController extends AbstractController ->setAlertSent($this->pool->getItem('stats.alert.sent')->get() ?? 0) ->setDomainTracked( - $this->getCachedItem('stats.domain.tracked', fn () => $this->watchListRepository->getTrackedDomainCount()) + $this->getCachedItem('stats.domain.tracked', fn () => $this->watchlistRepository->getTrackedDomainCount()) ) ->setDomainCount( $this->getCachedItem('stats.domain.count', fn () => $this->domainRepository->getActiveDomainCountByTld()) diff --git a/src/Controller/WatchListController.php b/src/Controller/WatchlistController.php similarity index 90% rename from src/Controller/WatchListController.php rename to src/Controller/WatchlistController.php index 8887e5d..16b59a9 100644 --- a/src/Controller/WatchListController.php +++ b/src/Controller/WatchlistController.php @@ -6,9 +6,9 @@ use App\Entity\Domain; use App\Entity\DomainEvent; use App\Entity\DomainStatus; use App\Entity\User; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Repository\DomainRepository; -use App\Repository\WatchListRepository; +use App\Repository\WatchlistRepository; use App\Service\CalendarService; use App\Service\RDAPService; use Doctrine\Common\Collections\Collection; @@ -26,10 +26,10 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; -class WatchListController extends AbstractController +class WatchlistController extends AbstractController { public function __construct( - private readonly WatchListRepository $watchListRepository, + private readonly WatchlistRepository $watchlistRepository, private readonly RDAPService $RDAPService, private readonly CalendarService $calendarService, private readonly DomainRepository $domainRepository, @@ -40,17 +40,17 @@ class WatchListController extends AbstractController path: '/api/watchlists', name: 'watchlist_get_all_mine', defaults: [ - '_api_resource_class' => WatchList::class, + '_api_resource_class' => Watchlist::class, '_api_operation_name' => 'get_all_mine', ], methods: ['GET'] )] - public function getWatchLists(): Collection + public function getWatchlists(): Collection { /** @var User $user */ $user = $this->getUser(); - return $user->getWatchLists(); + return $user->getWatchlists(); } /** @@ -63,26 +63,26 @@ class WatchListController extends AbstractController path: '/api/watchlists/{token}/calendar', name: 'watchlist_calendar', defaults: [ - '_api_resource_class' => WatchList::class, + '_api_resource_class' => Watchlist::class, '_api_operation_name' => 'calendar', ] )] public function getWatchlistCalendar(string $token): Response { - /** @var WatchList $watchList */ - $watchList = $this->watchListRepository->findOneBy(['token' => $token]); + /** @var Watchlist $watchlist */ + $watchlist = $this->watchlistRepository->findOneBy(['token' => $token]); $calendar = new Calendar(); /** @var Domain $domain */ - foreach ($watchList->getDomains()->getIterator() as $domain) { + foreach ($watchlist->getDomains()->getIterator() as $domain) { foreach ($this->calendarService->getDomainCalendarEvents($domain) as $event) { $calendar->addEvent($event); } } $calendarResponse = (new CalendarFactory())->createCalendar($calendar); - $calendarName = $watchList->getName(); + $calendarName = $watchlist->getName(); if (null !== $calendarName) { $calendarResponse->withProperty(new Property('X-WR-CALNAME', new TextValue($calendarName))); } @@ -99,7 +99,7 @@ class WatchListController extends AbstractController path: '/api/tracked', name: 'watchlist_get_tracked_domains', defaults: [ - '_api_resource_class' => WatchList::class, + '_api_resource_class' => Watchlist::class, '_api_operation_name' => 'get_tracked_domains', ] )] @@ -125,14 +125,14 @@ class WatchListController extends AbstractController path: '/api/watchlists/{token}/rss/events', name: 'watchlist_rss_events', defaults: [ - '_api_resource_class' => WatchList::class, + '_api_resource_class' => Watchlist::class, '_api_operation_name' => 'rss_events', ] )] public function getWatchlistRssEventsFeed(string $token, Request $request): Response { - /** @var WatchList $watchlist */ - $watchlist = $this->watchListRepository->findOneBy(['token' => $token]); + /** @var Watchlist $watchlist */ + $watchlist = $this->watchlistRepository->findOneBy(['token' => $token]); $feed = (new Feed()) ->setLanguage('en') @@ -163,14 +163,14 @@ class WatchListController extends AbstractController path: '/api/watchlists/{token}/rss/status', name: 'watchlist_rss_status', defaults: [ - '_api_resource_class' => WatchList::class, + '_api_resource_class' => Watchlist::class, '_api_operation_name' => 'rss_status', ] )] public function getWatchlistRssStatusFeed(string $token, Request $request): Response { - /** @var WatchList $watchlist */ - $watchlist = $this->watchListRepository->findOneBy(['token' => $token]); + /** @var Watchlist $watchlist */ + $watchlist = $this->watchlistRepository->findOneBy(['token' => $token]); $feed = (new Feed()) ->setLanguage('en') diff --git a/src/Entity/Connector.php b/src/Entity/Connector.php index e18a3e2..e4b1740 100644 --- a/src/Entity/Connector.php +++ b/src/Entity/Connector.php @@ -61,10 +61,10 @@ class Connector private array $authData = []; /** - * @var Collection + * @var Collection */ - #[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'connector')] - private Collection $watchLists; + #[ORM\OneToMany(targetEntity: Watchlist::class, mappedBy: 'connector')] + private Collection $watchlists; #[Groups(['connector:list', 'watchlist:list'])] #[ORM\Column] @@ -76,7 +76,7 @@ class Connector public function __construct() { $this->id = Uuid::v4(); - $this->watchLists = new ArrayCollection(); + $this->watchlists = new ArrayCollection(); } public function getId(): ?string @@ -121,29 +121,29 @@ class Connector } /** - * @return Collection + * @return Collection */ - public function getWatchLists(): Collection + public function getWatchlists(): Collection { - return $this->watchLists; + return $this->watchlists; } - public function addWatchList(WatchList $watchList): static + public function addWatchlist(Watchlist $watchlist): static { - if (!$this->watchLists->contains($watchList)) { - $this->watchLists->add($watchList); - $watchList->setConnector($this); + if (!$this->watchlists->contains($watchlist)) { + $this->watchlists->add($watchlist); + $watchlist->setConnector($this); } return $this; } - public function removeWatchList(WatchList $watchList): static + public function removeWatchlist(Watchlist $watchlist): static { - if ($this->watchLists->removeElement($watchList)) { + if ($this->watchlists->removeElement($watchlist)) { // set the owning side to null (unless already changed) - if ($watchList->getConnector() === $this) { - $watchList->setConnector(null); + if ($watchlist->getConnector() === $this) { + $watchlist->setConnector(null); } } @@ -164,6 +164,6 @@ class Connector public function getWatchlistCount(): ?int { - return $this->watchLists->count(); + return $this->watchlists->count(); } } diff --git a/src/Entity/Domain.php b/src/Entity/Domain.php index 68f1c66..ea0d906 100644 --- a/src/Entity/Domain.php +++ b/src/Entity/Domain.php @@ -82,10 +82,10 @@ class Domain private array $status = []; /** - * @var Collection + * @var Collection */ - #[ORM\ManyToMany(targetEntity: WatchList::class, mappedBy: 'domains', cascade: ['persist'])] - private Collection $watchLists; + #[ORM\ManyToMany(targetEntity: Watchlist::class, mappedBy: 'domains', cascade: ['persist'])] + private Collection $watchlists; /** * @var Collection @@ -154,7 +154,7 @@ class Domain { $this->events = new ArrayCollection(); $this->domainEntities = new ArrayCollection(); - $this->watchLists = new ArrayCollection(); + $this->watchlists = new ArrayCollection(); $this->nameservers = new ArrayCollection(); $this->updatedAt = new \DateTimeImmutable('now'); $this->createdAt = $this->updatedAt; @@ -263,27 +263,27 @@ class Domain } /** - * @return Collection + * @return Collection */ - public function getWatchLists(): Collection + public function getWatchlists(): Collection { - return $this->watchLists; + return $this->watchlists; } - public function addWatchList(WatchList $watchList): static + public function addWatchlists(Watchlist $watchlist): static { - if (!$this->watchLists->contains($watchList)) { - $this->watchLists->add($watchList); - $watchList->addDomain($this); + if (!$this->watchlists->contains($watchlist)) { + $this->watchlists->add($watchlist); + $watchlist->addDomain($this); } return $this; } - public function removeWatchList(WatchList $watchList): static + public function removeWatchlists(Watchlist $watchlist): static { - if ($this->watchLists->removeElement($watchList)) { - $watchList->removeDomain($this); + if ($this->watchlists->removeElement($watchlist)) { + $watchlist->removeDomain($this); } return $this; diff --git a/src/Entity/User.php b/src/Entity/User.php index f709cf9..29fa9f5 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -66,10 +66,10 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface private ?string $password = null; /** - * @var Collection + * @var Collection */ - #[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'user', orphanRemoval: true)] - private Collection $watchLists; + #[ORM\OneToMany(targetEntity: Watchlist::class, mappedBy: 'user', orphanRemoval: true)] + private Collection $watchlists; /** * @var Collection @@ -91,7 +91,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface public function __construct() { - $this->watchLists = new ArrayCollection(); + $this->watchlists = new ArrayCollection(); $this->connectors = new ArrayCollection(); } @@ -168,29 +168,29 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface } /** - * @return Collection + * @return Collection */ - public function getWatchLists(): Collection + public function getWatchlists(): Collection { - return $this->watchLists; + return $this->watchlists; } - public function addWatchList(WatchList $watchList): static + public function addWatchlist(Watchlist $watchlist): static { - if (!$this->watchLists->contains($watchList)) { - $this->watchLists->add($watchList); - $watchList->setUser($this); + if (!$this->watchlists->contains($watchlist)) { + $this->watchlists->add($watchlist); + $watchlist->setUser($this); } return $this; } - public function removeWatchList(WatchList $watchList): static + public function removeWatchlist(Watchlist $watchlist): static { - if ($this->watchLists->removeElement($watchList)) { + if ($this->watchlists->removeElement($watchlist)) { // set the owning side to null (unless already changed) - if ($watchList->getUser() === $this) { - $watchList->setUser(null); + if ($watchlist->getUser() === $this) { + $watchlist->setUser(null); } } diff --git a/src/Entity/WatchList.php b/src/Entity/Watchlist.php similarity index 94% rename from src/Entity/WatchList.php rename to src/Entity/Watchlist.php index 736be2f..ed243c4 100644 --- a/src/Entity/WatchList.php +++ b/src/Entity/Watchlist.php @@ -8,8 +8,8 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Put; -use App\Repository\WatchListRepository; -use App\State\WatchListUpdateProcessor; +use App\Repository\WatchlistRepository; +use App\State\WatchlistUpdateProcessor; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; @@ -19,7 +19,7 @@ use Symfony\Component\Serializer\Attribute\SerializedName; use Symfony\Component\Uid\Uuid; use Symfony\Component\Validator\Constraints as Assert; -#[ORM\Entity(repositoryClass: WatchListRepository::class)] +#[ORM\Entity(repositoryClass: WatchlistRepository::class)] #[ApiResource( shortName: 'Watchlist', operations: [ @@ -87,13 +87,13 @@ use Symfony\Component\Validator\Constraints as Assert; new Post( normalizationContext: ['groups' => 'watchlist:list'], denormalizationContext: ['groups' => 'watchlist:create'], - processor: WatchListUpdateProcessor::class, + processor: WatchlistUpdateProcessor::class, ), new Put( normalizationContext: ['groups' => 'watchlist:list'], denormalizationContext: ['groups' => ['watchlist:update']], security: 'object.getUser() == user', - processor: WatchListUpdateProcessor::class, + processor: WatchlistUpdateProcessor::class, ), new Delete( security: 'object.getUser() == user' @@ -146,9 +146,9 @@ use Symfony\Component\Validator\Constraints as Assert; ), ], )] -class WatchList +class Watchlist { - #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'watchLists')] + #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'watchlists')] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] public ?User $user = null; @@ -160,14 +160,14 @@ class WatchList /** * @var Collection */ - #[ORM\ManyToMany(targetEntity: Domain::class, inversedBy: 'watchLists')] - #[ORM\JoinTable(name: 'watch_lists_domains', - joinColumns: [new ORM\JoinColumn(name: 'watch_list_token', referencedColumnName: 'token', onDelete: 'CASCADE')], + #[ORM\ManyToMany(targetEntity: Domain::class, inversedBy: 'watchlists')] + #[ORM\JoinTable(name: 'watchlist_domains', + joinColumns: [new ORM\JoinColumn(name: 'watchlist_token', referencedColumnName: 'token', onDelete: 'CASCADE')], inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name', onDelete: 'CASCADE')])] #[Groups(['watchlist:create', 'watchlist:list', 'watchlist:item', 'watchlist:update'])] private Collection $domains; - #[ORM\ManyToOne(inversedBy: 'watchLists')] + #[ORM\ManyToOne(inversedBy: 'watchlists')] #[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])] private ?Connector $connector = null; diff --git a/src/Message/OrderDomain.php b/src/Message/OrderDomain.php index fd3988f..61ec9ad 100644 --- a/src/Message/OrderDomain.php +++ b/src/Message/OrderDomain.php @@ -5,7 +5,7 @@ namespace App\Message; final class OrderDomain { public function __construct( - public string $watchListToken, + public string $watchlistToken, public string $ldhName, ) { } diff --git a/src/Message/ProcessWatchListsTrigger.php b/src/Message/ProcessWatchlistTrigger.php similarity index 87% rename from src/Message/ProcessWatchListsTrigger.php rename to src/Message/ProcessWatchlistTrigger.php index e84c940..4e44f16 100644 --- a/src/Message/ProcessWatchListsTrigger.php +++ b/src/Message/ProcessWatchlistTrigger.php @@ -2,7 +2,7 @@ namespace App\Message; -final class ProcessWatchListsTrigger +final class ProcessWatchlistTrigger { /* * Add whatever properties and methods you need diff --git a/src/Message/SendDomainEventNotif.php b/src/Message/SendDomainEventNotif.php index 1fae087..9866617 100644 --- a/src/Message/SendDomainEventNotif.php +++ b/src/Message/SendDomainEventNotif.php @@ -5,7 +5,7 @@ namespace App\Message; final class SendDomainEventNotif { public function __construct( - public string $watchListToken, + public string $watchlistToken, public string $ldhName, public \DateTimeImmutable $updatedAt, ) { diff --git a/src/Message/UpdateDomainsFromWatchlist.php b/src/Message/UpdateDomainsFromWatchlist.php index 1fbc98b..41bed74 100644 --- a/src/Message/UpdateDomainsFromWatchlist.php +++ b/src/Message/UpdateDomainsFromWatchlist.php @@ -5,7 +5,7 @@ namespace App\Message; final readonly class UpdateDomainsFromWatchlist { public function __construct( - public string $watchListToken, + public string $watchlistToken, ) { } } diff --git a/src/MessageHandler/OrderDomainHandler.php b/src/MessageHandler/OrderDomainHandler.php index c4faab0..72c6fd3 100644 --- a/src/MessageHandler/OrderDomainHandler.php +++ b/src/MessageHandler/OrderDomainHandler.php @@ -3,12 +3,12 @@ namespace App\MessageHandler; use App\Entity\Domain; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Message\OrderDomain; use App\Notifier\DomainOrderErrorNotification; use App\Notifier\DomainOrderNotification; use App\Repository\DomainRepository; -use App\Repository\WatchListRepository; +use App\Repository\WatchlistRepository; use App\Service\ChatNotificationService; use App\Service\InfluxdbService; use App\Service\Provider\AbstractProvider; @@ -31,7 +31,7 @@ final readonly class OrderDomainHandler public function __construct( string $mailerSenderEmail, string $mailerSenderName, - private WatchListRepository $watchListRepository, + private WatchlistRepository $watchlistRepository, private DomainRepository $domainRepository, private KernelInterface $kernel, private MailerInterface $mailer, @@ -54,12 +54,12 @@ final readonly class OrderDomainHandler */ public function __invoke(OrderDomain $message): void { - /** @var WatchList $watchList */ - $watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]); + /** @var Watchlist $watchlist */ + $watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]); /** @var Domain $domain */ $domain = $this->domainRepository->findOneBy(['ldhName' => $message->ldhName]); - $connector = $watchList->getConnector(); + $connector = $watchlist->getConnector(); /* * We make sure that the domain name is marked absent from WHOIS in the database before continuing. @@ -72,7 +72,7 @@ final readonly class OrderDomainHandler } $this->logger->notice('Watchlist is linked to a connector : a purchase attempt will be made for this domain name', [ - 'watchlist' => $message->watchListToken, + 'watchlist' => $message->watchlistToken, 'connector' => $connector->getId(), 'ldhName' => $message->ldhName, 'provider' => $connector->getProvider()->value, @@ -101,7 +101,7 @@ final readonly class OrderDomainHandler * If the purchase was successful, the statistics are updated and a success message is sent to the user. */ $this->logger->notice('Watchlist is linked to connector : a purchase was successfully made for this domain name', [ - 'watchlist' => $message->watchListToken, + 'watchlist' => $message->watchlistToken, 'connector' => $connector->getId(), 'ldhName' => $message->ldhName, 'provider' => $connector->getProvider()->value, @@ -112,15 +112,15 @@ final readonly class OrderDomainHandler $this->influxdbService->addDomainOrderPoint($connector, $domain, true); } $notification = (new DomainOrderNotification($this->sender, $domain, $connector)); - $this->mailer->send($notification->asEmailMessage(new Recipient($watchList->getUser()->getEmail()))->getMessage()); - $this->chatNotificationService->sendChatNotification($watchList, $notification); + $this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage()); + $this->chatNotificationService->sendChatNotification($watchlist, $notification); } catch (\Throwable $exception) { /* * The purchase was not successful (for several possible reasons that we have not determined). * The user is informed and the exception is raised, which may allow you to try again. */ $this->logger->warning('Unable to complete purchase : an error message is sent to the user', [ - 'watchlist' => $message->watchListToken, + 'watchlist' => $message->watchlistToken, 'connector' => $connector->getId(), 'ldhName' => $message->ldhName, 'provider' => $connector->getProvider()->value, @@ -131,8 +131,8 @@ final readonly class OrderDomainHandler $this->influxdbService->addDomainOrderPoint($connector, $domain, false); } $notification = (new DomainOrderErrorNotification($this->sender, $domain)); - $this->mailer->send($notification->asEmailMessage(new Recipient($watchList->getUser()->getEmail()))->getMessage()); - $this->chatNotificationService->sendChatNotification($watchList, $notification); + $this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage()); + $this->chatNotificationService->sendChatNotification($watchlist, $notification); throw $exception; } diff --git a/src/MessageHandler/ProcessWatchListsTriggerHandler.php b/src/MessageHandler/ProcessWatchlistTriggerHandler.php similarity index 63% rename from src/MessageHandler/ProcessWatchListsTriggerHandler.php rename to src/MessageHandler/ProcessWatchlistTriggerHandler.php index 492bc72..1cc18eb 100644 --- a/src/MessageHandler/ProcessWatchListsTriggerHandler.php +++ b/src/MessageHandler/ProcessWatchlistTriggerHandler.php @@ -2,20 +2,20 @@ namespace App\MessageHandler; -use App\Entity\WatchList; -use App\Message\ProcessWatchListsTrigger; +use App\Entity\Watchlist; +use App\Message\ProcessWatchlistTrigger; use App\Message\UpdateDomainsFromWatchlist; -use App\Repository\WatchListRepository; +use App\Repository\WatchlistRepository; use Random\Randomizer; use Symfony\Component\Messenger\Attribute\AsMessageHandler; use Symfony\Component\Messenger\Exception\ExceptionInterface; use Symfony\Component\Messenger\MessageBusInterface; #[AsMessageHandler] -final readonly class ProcessWatchListsTriggerHandler +final readonly class ProcessWatchlistTriggerHandler { public function __construct( - private WatchListRepository $watchListRepository, + private WatchlistRepository $watchlistRepository, private MessageBusInterface $bus, ) { } @@ -23,7 +23,7 @@ final readonly class ProcessWatchListsTriggerHandler /** * @throws ExceptionInterface */ - public function __invoke(ProcessWatchListsTrigger $message): void + public function __invoke(ProcessWatchlistTrigger $message): void { /* * We shuffle the watch lists to process them in an order that we consider random. @@ -31,11 +31,11 @@ final readonly class ProcessWatchListsTriggerHandler */ $randomizer = new Randomizer(); - $watchLists = $randomizer->shuffleArray($this->watchListRepository->findAll()); + $watchlists = $randomizer->shuffleArray($this->watchlistRepository->findAll()); - /** @var WatchList $watchList */ - foreach ($watchLists as $watchList) { - $this->bus->dispatch(new UpdateDomainsFromWatchlist($watchList->getToken())); + /** @var Watchlist $watchlist */ + foreach ($watchlists as $watchlist) { + $this->bus->dispatch(new UpdateDomainsFromWatchlist($watchlist->getToken())); } } } diff --git a/src/MessageHandler/SendDomainEventNotifHandler.php b/src/MessageHandler/SendDomainEventNotifHandler.php index 565e30f..bf519df 100644 --- a/src/MessageHandler/SendDomainEventNotifHandler.php +++ b/src/MessageHandler/SendDomainEventNotifHandler.php @@ -5,14 +5,14 @@ namespace App\MessageHandler; use App\Entity\Domain; use App\Entity\DomainEvent; use App\Entity\DomainStatus; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Message\SendDomainEventNotif; use App\Notifier\DomainStatusUpdateNotification; use App\Notifier\DomainUpdateNotification; use App\Repository\DomainEventRepository; use App\Repository\DomainRepository; use App\Repository\DomainStatusRepository; -use App\Repository\WatchListRepository; +use App\Repository\WatchlistRepository; use App\Service\ChatNotificationService; use App\Service\InfluxdbService; use App\Service\StatService; @@ -36,7 +36,7 @@ final readonly class SendDomainEventNotifHandler private MailerInterface $mailer, private StatService $statService, private DomainRepository $domainRepository, - private WatchListRepository $watchListRepository, + private WatchlistRepository $watchlistRepository, private ChatNotificationService $chatNotificationService, #[Autowire(param: 'influxdb_enabled')] private bool $influxdbEnabled, @@ -53,11 +53,11 @@ final readonly class SendDomainEventNotifHandler */ public function __invoke(SendDomainEventNotif $message): void { - /** @var WatchList $watchList */ - $watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]); + /** @var Watchlist $watchlist */ + $watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]); /** @var Domain $domain */ $domain = $this->domainRepository->findOneBy(['ldhName' => $message->ldhName]); - $recipient = new Recipient($watchList->getUser()->getEmail()); + $recipient = new Recipient($watchlist->getUser()->getEmail()); /* * For each new event whose date is after the domain name update date (before the current domain name update) @@ -67,7 +67,7 @@ final readonly class SendDomainEventNotifHandler $newEvents = $this->domainEventRepository->findNewDomainEvents($domain, $message->updatedAt); foreach ($newEvents as $event) { - if (!in_array($event->getAction(), $watchList->getTrackedEvents())) { + if (!in_array($event->getAction(), $watchlist->getTrackedEvents())) { continue; } @@ -76,7 +76,7 @@ final readonly class SendDomainEventNotifHandler $this->logger->info('New action has been detected on this domain name : an email is sent to user', [ 'event' => $event->getAction(), 'ldhName' => $message->ldhName, - 'username' => $watchList->getUser()->getUserIdentifier(), + 'username' => $watchlist->getUser()->getUserIdentifier(), ]); $this->mailer->send($notification->asEmailMessage($recipient)->getMessage()); @@ -85,15 +85,15 @@ final readonly class SendDomainEventNotifHandler $this->influxdbService->addDomainNotificationPoint($domain, 'email', true); } - $webhookDsn = $watchList->getWebhookDsn(); + $webhookDsn = $watchlist->getWebhookDsn(); if (null !== $webhookDsn && 0 !== count($webhookDsn)) { $this->logger->info('New action has been detected on this domain name : a notification is sent to user', [ 'event' => $event->getAction(), 'ldhName' => $message->ldhName, - 'username' => $watchList->getUser()->getUserIdentifier(), + 'username' => $watchlist->getUser()->getUserIdentifier(), ]); - $this->chatNotificationService->sendChatNotification($watchList, $notification); + $this->chatNotificationService->sendChatNotification($watchlist, $notification); if ($this->influxdbEnabled) { $this->influxdbService->addDomainNotificationPoint($domain, 'chat', true); } @@ -106,7 +106,7 @@ final readonly class SendDomainEventNotifHandler $domainStatus = $this->domainStatusRepository->findNewDomainStatus($domain, $message->updatedAt); if (null !== $domainStatus && count(array_intersect( - $watchList->getTrackedEppStatus(), + $watchlist->getTrackedEppStatus(), [...$domainStatus->getAddStatus(), ...$domainStatus->getDeleteStatus()] ))) { $notification = new DomainStatusUpdateNotification($this->sender, $domain, $domainStatus); @@ -116,7 +116,7 @@ final readonly class SendDomainEventNotifHandler 'deleteStatus' => $domainStatus->getDeleteStatus(), 'status' => $domain->getStatus(), 'ldhName' => $message->ldhName, - 'username' => $watchList->getUser()->getUserIdentifier(), + 'username' => $watchlist->getUser()->getUserIdentifier(), ]); $this->mailer->send($notification->asEmailMessage($recipient)->getMessage()); @@ -125,17 +125,17 @@ final readonly class SendDomainEventNotifHandler $this->influxdbService->addDomainNotificationPoint($domain, 'email', true); } - $webhookDsn = $watchList->getWebhookDsn(); + $webhookDsn = $watchlist->getWebhookDsn(); if (null !== $webhookDsn && 0 !== count($webhookDsn)) { $this->logger->info('New domain status has been detected on this domain name : a notification is sent to user', [ 'addStatus' => $domainStatus->getAddStatus(), 'deleteStatus' => $domainStatus->getDeleteStatus(), 'status' => $domain->getStatus(), 'ldhName' => $message->ldhName, - 'username' => $watchList->getUser()->getUserIdentifier(), + 'username' => $watchlist->getUser()->getUserIdentifier(), ]); - $this->chatNotificationService->sendChatNotification($watchList, $notification); + $this->chatNotificationService->sendChatNotification($watchlist, $notification); if ($this->influxdbEnabled) { $this->influxdbService->addDomainNotificationPoint($domain, 'chat', true); diff --git a/src/MessageHandler/UpdateDomainsFromWatchlistHandler.php b/src/MessageHandler/UpdateDomainsFromWatchlistHandler.php index e6bdf1f..c0aa1e8 100644 --- a/src/MessageHandler/UpdateDomainsFromWatchlistHandler.php +++ b/src/MessageHandler/UpdateDomainsFromWatchlistHandler.php @@ -3,7 +3,7 @@ namespace App\MessageHandler; use App\Entity\Domain; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Exception\DomainNotFoundException; use App\Exception\TldNotSupportedException; use App\Exception\UnknownRdapServerException; @@ -12,7 +12,7 @@ use App\Message\SendDomainEventNotif; use App\Message\UpdateDomainsFromWatchlist; use App\Notifier\DomainDeletedNotification; use App\Repository\DomainRepository; -use App\Repository\WatchListRepository; +use App\Repository\WatchlistRepository; use App\Service\ChatNotificationService; use App\Service\Provider\AbstractProvider; use App\Service\Provider\CheckDomainProviderInterface; @@ -38,7 +38,7 @@ final readonly class UpdateDomainsFromWatchlistHandler string $mailerSenderEmail, string $mailerSenderName, private MessageBusInterface $bus, - private WatchListRepository $watchListRepository, + private WatchlistRepository $watchlistRepository, private LoggerInterface $logger, #[Autowire(service: 'service_container')] private ContainerInterface $locator, @@ -52,29 +52,29 @@ final readonly class UpdateDomainsFromWatchlistHandler */ public function __invoke(UpdateDomainsFromWatchlist $message): void { - /** @var WatchList $watchList */ - $watchList = $this->watchListRepository->findOneBy(['token' => $message->watchListToken]); + /** @var Watchlist $watchlist */ + $watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]); $this->logger->debug('Domain names listed in the Watchlist will be updated', [ - 'watchlist' => $message->watchListToken, + 'watchlist' => $message->watchlistToken, ]); /** @var AbstractProvider $connectorProvider */ - $connectorProvider = $this->getConnectorProvider($watchList); + $connectorProvider = $this->getConnectorProvider($watchlist); if ($connectorProvider instanceof CheckDomainProviderInterface) { $this->logger->debug('Watchlist is linked to a connector', [ - 'watchlist' => $watchList->getToken(), - 'connector' => $watchList->getConnector()->getId(), + 'watchlist' => $watchlist->getToken(), + 'connector' => $watchlist->getConnector()->getId(), ]); - $domainList = array_unique(array_map(fn (Domain $d) => $d->getLdhName(), $watchList->getDomains()->toArray())); + $domainList = array_unique(array_map(fn (Domain $d) => $d->getLdhName(), $watchlist->getDomains()->toArray())); try { $checkedDomains = $connectorProvider->checkDomains(...$domainList); } catch (\Throwable $exception) { $this->logger->warning('Unable to check domain names availability with this connector', [ - 'connector' => $watchList->getConnector()->getId(), + 'connector' => $watchlist->getConnector()->getId(), 'ldhName' => $domainList, ]); @@ -82,7 +82,7 @@ final readonly class UpdateDomainsFromWatchlistHandler } foreach ($checkedDomains as $domain) { - $this->bus->dispatch(new OrderDomain($watchList->getToken(), $domain)); + $this->bus->dispatch(new OrderDomain($watchlist->getToken(), $domain)); } return; @@ -96,7 +96,7 @@ final readonly class UpdateDomainsFromWatchlistHandler */ /** @var Domain $domain */ - foreach ($watchList->getDomains()->filter(fn ($domain) => $this->RDAPService->isToBeUpdated($domain, false, null !== $watchList->getConnector())) as $domain + foreach ($watchlist->getDomains()->filter(fn ($domain) => $this->RDAPService->isToBeUpdated($domain, false, null !== $watchlist->getConnector())) as $domain ) { $updatedAt = $domain->getUpdatedAt(); $deleted = $domain->getDeleted(); @@ -107,22 +107,22 @@ final readonly class UpdateDomainsFromWatchlistHandler * We send messages that correspond to the sending of notifications that will not be processed here. */ $this->RDAPService->registerDomain($domain->getLdhName()); - $this->bus->dispatch(new SendDomainEventNotif($watchList->getToken(), $domain->getLdhName(), $updatedAt)); + $this->bus->dispatch(new SendDomainEventNotif($watchlist->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); + $this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage()); + $this->chatNotificationService->sendChatNotification($watchlist, $notification); } - if ($watchList->getConnector()) { + 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())); + $this->bus->dispatch(new OrderDomain($watchlist->getToken(), $domain->getLdhName())); } } catch (TldNotSupportedException|UnknownRdapServerException) { /* @@ -132,9 +132,9 @@ final readonly class UpdateDomainsFromWatchlistHandler } } - private function getConnectorProvider(WatchList $watchList): ?object + private function getConnectorProvider(Watchlist $watchlist): ?object { - $connector = $watchList->getConnector(); + $connector = $watchlist->getConnector(); if (null === $connector || null === $connector->getProvider()) { return null; } diff --git a/src/Notifier/DomainUpdateNotification.php b/src/Notifier/DomainUpdateNotification.php index ff92480..f0c8073 100644 --- a/src/Notifier/DomainUpdateNotification.php +++ b/src/Notifier/DomainUpdateNotification.php @@ -27,7 +27,7 @@ class DomainUpdateNotification extends DomainWatchdogNotification $ldhName = $this->domainEvent->getDomain()->getLdhName(); $action = $this->domainEvent->getAction(); $this->subject("Domain changed $ldhName ($action)") - ->content("Domain name $ldhName information has been updated ($action).") + ->content("Domain name $ldhName events has been updated ($action).") ->importance(Notification::IMPORTANCE_HIGH); return ChatMessage::fromNotification($this); @@ -38,7 +38,7 @@ class DomainUpdateNotification extends DomainWatchdogNotification $ldhName = $this->domainEvent->getDomain()->getLdhName(); $action = $this->domainEvent->getAction(); $this->subject("Domain changed $ldhName ($action)") - ->content("Domain name $ldhName information has been updated ($action).") + ->content("Domain name $ldhName events has been updated ($action).") ->importance(Notification::IMPORTANCE_HIGH); return PushMessage::fromNotification($this); @@ -52,8 +52,8 @@ class DomainUpdateNotification extends DomainWatchdogNotification ->from($this->sender) ->to($recipient->getEmail()) ->priority(Email::PRIORITY_HIGH) - ->subject("Domain name $ldhName information has been updated") - ->htmlTemplate('emails/success/domain_updated.html.twig') + ->subject("Domain name $ldhName events has been updated") + ->htmlTemplate('emails/success/domain_event_updated.html.twig') ->locale('en') ->context([ 'event' => $this->domainEvent, diff --git a/src/Repository/DomainRepository.php b/src/Repository/DomainRepository.php index 85b694d..e4e9527 100644 --- a/src/Repository/DomainRepository.php +++ b/src/Repository/DomainRepository.php @@ -55,7 +55,7 @@ class DomainRepository extends ServiceEntityRepository public function getMyTrackedDomains(User $user): array { return $this->createQueryBuilder('d') - ->join('d.watchLists', 'w') + ->join('d.watchlists', 'w') ->where('w.user = :user') ->andWhere('d.deleted = false') ->setParameter('user', $user) diff --git a/src/Repository/WatchListRepository.php b/src/Repository/WatchlistRepository.php similarity index 79% rename from src/Repository/WatchListRepository.php rename to src/Repository/WatchlistRepository.php index 27f10c9..caaab59 100644 --- a/src/Repository/WatchListRepository.php +++ b/src/Repository/WatchlistRepository.php @@ -2,18 +2,18 @@ namespace App\Repository; -use App\Entity\WatchList; +use App\Entity\Watchlist; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; /** - * @extends ServiceEntityRepository + * @extends ServiceEntityRepository */ -class WatchListRepository extends ServiceEntityRepository +class WatchlistRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { - parent::__construct($registry, WatchList::class); + parent::__construct($registry, Watchlist::class); } public function getTrackedDomainCount() @@ -26,7 +26,7 @@ class WatchListRepository extends ServiceEntityRepository } // /** - // * @return WatchList[] Returns an array of WatchList objects + // * @return Watchlist[] Returns an array of Watchlist objects // */ // public function findByExampleField($value): array // { @@ -40,7 +40,7 @@ class WatchListRepository extends ServiceEntityRepository // ; // } - // public function findOneBySomeField($value): ?WatchList + // public function findOneBySomeField($value): ?Watchlist // { // return $this->createQueryBuilder('b') // ->andWhere('b.exampleField = :val') diff --git a/src/Scheduler/SendNotifWatchListTriggerSchedule.php b/src/Scheduler/SendNotifWatchlistTriggerSchedule.php similarity index 83% rename from src/Scheduler/SendNotifWatchListTriggerSchedule.php rename to src/Scheduler/SendNotifWatchlistTriggerSchedule.php index 2d90651..bad174e 100644 --- a/src/Scheduler/SendNotifWatchListTriggerSchedule.php +++ b/src/Scheduler/SendNotifWatchlistTriggerSchedule.php @@ -2,7 +2,7 @@ namespace App\Scheduler; -use App\Message\ProcessWatchListsTrigger; +use App\Message\ProcessWatchlistTrigger; use Symfony\Component\Scheduler\Attribute\AsSchedule; use Symfony\Component\Scheduler\RecurringMessage; use Symfony\Component\Scheduler\Schedule; @@ -10,7 +10,7 @@ use Symfony\Component\Scheduler\ScheduleProviderInterface; use Symfony\Contracts\Cache\CacheInterface; #[AsSchedule('notif_watchlist')] -final readonly class SendNotifWatchListTriggerSchedule implements ScheduleProviderInterface +final readonly class SendNotifWatchlistTriggerSchedule implements ScheduleProviderInterface { public function __construct( private CacheInterface $cache, @@ -21,7 +21,7 @@ final readonly class SendNotifWatchListTriggerSchedule implements ScheduleProvid { return (new Schedule()) ->add( - RecurringMessage::every('5 minutes', new ProcessWatchListsTrigger()), + RecurringMessage::every('5 minutes', new ProcessWatchlistTrigger()), ) ->stateful($this->cache); } diff --git a/src/Service/ChatNotificationService.php b/src/Service/ChatNotificationService.php index c8788f7..bfef162 100644 --- a/src/Service/ChatNotificationService.php +++ b/src/Service/ChatNotificationService.php @@ -3,7 +3,7 @@ namespace App\Service; use App\Config\WebhookScheme; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Exception\UnsupportedDsnSchemeException; use App\Notifier\DomainWatchdogNotification; use Symfony\Component\Notifier\Exception\TransportExceptionInterface; @@ -21,9 +21,9 @@ readonly class ChatNotificationService * @throws UnsupportedDsnSchemeException * @throws TransportExceptionInterface */ - public function sendChatNotification(WatchList $watchList, DomainWatchdogNotification $notification): void + public function sendChatNotification(Watchlist $watchlist, DomainWatchdogNotification $notification): void { - $webhookDsn = $watchList->getWebhookDsn(); + $webhookDsn = $watchlist->getWebhookDsn(); if (empty($webhookDsn)) { return; diff --git a/src/State/AutoRegisterDomainProvider.php b/src/State/AutoRegisterDomainProvider.php index 5810dba..f378e22 100644 --- a/src/State/AutoRegisterDomainProvider.php +++ b/src/State/AutoRegisterDomainProvider.php @@ -5,7 +5,7 @@ namespace App\State; use ApiPlatform\Metadata\Operation; use ApiPlatform\State\ProviderInterface; use App\Entity\Domain; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Exception\DomainNotFoundException; use App\Exception\MalformedDomainException; use App\Exception\TldNotSupportedException; @@ -100,11 +100,11 @@ readonly class AutoRegisterDomainProvider implements ProviderInterface $domain = $this->RDAPService->registerDomain($idnDomain); $randomizer = new Randomizer(); - $watchLists = $randomizer->shuffleArray($domain->getWatchLists()->toArray()); + $watchlists = $randomizer->shuffleArray($domain->getWatchlists()->toArray()); - /** @var WatchList $watchList */ - foreach ($watchLists as $watchList) { - $this->bus->dispatch(new SendDomainEventNotif($watchList->getToken(), $domain->getLdhName(), $updatedAt)); + /** @var Watchlist $watchlist */ + foreach ($watchlists as $watchlist) { + $this->bus->dispatch(new SendDomainEventNotif($watchlist->getToken(), $domain->getLdhName(), $updatedAt)); } return $domain; diff --git a/src/State/ConnectorDeleteProcessor.php b/src/State/ConnectorDeleteProcessor.php index 7d35fd4..3be3a26 100644 --- a/src/State/ConnectorDeleteProcessor.php +++ b/src/State/ConnectorDeleteProcessor.php @@ -30,7 +30,7 @@ readonly class ConnectorDeleteProcessor implements ProcessorInterface */ public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): mixed { - foreach ($data->getWatchLists()->getIterator() as $watchlist) { + foreach ($data->getWatchlists()->getIterator() as $watchlist) { $watchlist->setConnector(null); } diff --git a/src/State/WatchListUpdateProcessor.php b/src/State/WatchlistUpdateProcessor.php similarity index 93% rename from src/State/WatchListUpdateProcessor.php rename to src/State/WatchlistUpdateProcessor.php index 056abd9..5da190b 100644 --- a/src/State/WatchListUpdateProcessor.php +++ b/src/State/WatchlistUpdateProcessor.php @@ -6,7 +6,7 @@ use ApiPlatform\Metadata\Operation; use ApiPlatform\State\ProcessorInterface; use App\Entity\Domain; use App\Entity\User; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Notifier\TestChatNotification; use App\Service\ChatNotificationService; use App\Service\Provider\AbstractProvider; @@ -19,7 +19,7 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Serializer\Exception\ExceptionInterface; -readonly class WatchListUpdateProcessor implements ProcessorInterface +readonly class WatchlistUpdateProcessor implements ProcessorInterface { public function __construct( private Security $security, @@ -34,9 +34,9 @@ readonly class WatchListUpdateProcessor implements ProcessorInterface } /** - * @param WatchList $data + * @param Watchlist $data * - * @return WatchList + * @return Watchlist * * @throws ExceptionInterface * @throws \Exception @@ -57,12 +57,12 @@ readonly class WatchListUpdateProcessor implements ProcessorInterface throw new AccessDeniedHttpException('You have exceeded the maximum number of domain names allowed in this Watchlist'); } - $userWatchLists = $user->getWatchLists(); + $userWatchlists = $user->getWatchlists(); /** @var Domain[] $trackedDomains */ - $trackedDomains = $userWatchLists - ->filter(fn (WatchList $wl) => $wl->getToken() !== $data->getToken()) - ->reduce(fn (array $acc, WatchList $wl) => [...$acc, ...$wl->getDomains()->toArray()], []); + $trackedDomains = $userWatchlists + ->filter(fn (Watchlist $wl) => $wl->getToken() !== $data->getToken()) + ->reduce(fn (array $acc, Watchlist $wl) => [...$acc, ...$wl->getDomains()->toArray()], []); /** @var Domain $domain */ foreach ($data->getDomains()->getIterator() as $domain) { diff --git a/templates/emails/success/domain_updated.html.twig b/templates/emails/success/domain_event_updated.html.twig similarity index 100% rename from templates/emails/success/domain_updated.html.twig rename to templates/emails/success/domain_event_updated.html.twig diff --git a/tests/Controller/WatchlistControllerTest.php b/tests/Controller/WatchlistControllerTest.php index d75f802..ece8f9d 100644 --- a/tests/Controller/WatchlistControllerTest.php +++ b/tests/Controller/WatchlistControllerTest.php @@ -3,10 +3,10 @@ namespace App\Tests\Controller; use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Tests\AuthenticatedUserTrait; use App\Tests\Service\RDAPServiceTest; -use App\Tests\State\WatchListUpdateProcessorTest; +use App\Tests\State\WatchlistUpdateProcessorTest; use PHPUnit\Framework\Attributes\DependsExternal; use Zenstruck\Foundry\Test\Factories; @@ -18,12 +18,12 @@ final class WatchlistControllerTest extends ApiTestCase #[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')] public function testGetWatchlistCollection(): void { - $client = WatchListUpdateProcessorTest::createUserAndWatchlist(); + $client = WatchlistUpdateProcessorTest::createUserAndWatchlist(); $response = $client->request('GET', '/api/watchlists'); $this->assertResponseIsSuccessful(); - $this->assertMatchesResourceCollectionJsonSchema(WatchList::class); + $this->assertMatchesResourceCollectionJsonSchema(Watchlist::class); $data = $response->toArray(); $this->assertArrayHasKey('hydra:member', $data); @@ -33,7 +33,7 @@ final class WatchlistControllerTest extends ApiTestCase #[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')] public function testGetTrackedDomains() { - $client = WatchListUpdateProcessorTest::createUserAndWatchlist(null, ['/api/domains/example.org']); + $client = WatchlistUpdateProcessorTest::createUserAndWatchlist(null, ['/api/domains/example.org']); $response = $client->request('GET', '/api/tracked'); $this->assertResponseIsSuccessful(); @@ -46,7 +46,7 @@ final class WatchlistControllerTest extends ApiTestCase #[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')] public function testGetWatchlistFeeds() { - $client = WatchListUpdateProcessorTest::createUserAndWatchlist(); + $client = WatchlistUpdateProcessorTest::createUserAndWatchlist(); $response = $client->request('GET', '/api/watchlists'); $token = $response->toArray()['hydra:member'][0]['token']; diff --git a/tests/Service/Provider/AbstractProviderTest.php b/tests/Service/Provider/AbstractProviderTest.php index 3ba5356..713d7ac 100644 --- a/tests/Service/Provider/AbstractProviderTest.php +++ b/tests/Service/Provider/AbstractProviderTest.php @@ -6,13 +6,13 @@ use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; use App\Config\ConnectorProvider; use App\Entity\Domain; use App\Entity\Tld; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Factory\UserFactory; use App\Message\OrderDomain; use App\MessageHandler\OrderDomainHandler; use App\Tests\Controller\ConnectorControllerTest; use App\Tests\Service\RDAPServiceTest; -use App\Tests\State\WatchListUpdateProcessorTest; +use App\Tests\State\WatchlistUpdateProcessorTest; use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\Attributes\DependsExternal; use Symfony\Component\HttpClient\Exception\ServerException; @@ -89,12 +89,12 @@ class AbstractProviderTest extends ApiTestCase $entityManager = self::getContainer()->get(EntityManagerInterface::class); // Create a Watchlist with the domain name - WatchListUpdateProcessorTest::createUserAndWatchlist($client, + WatchlistUpdateProcessorTest::createUserAndWatchlist($client, ['/api/domains/example.com'], '/api/connectors/'.$response->toArray()['id']); $response = $client->request('GET', '/api/watchlists'); - $watchlist = $entityManager->getRepository(WatchList::class)->findOneBy(['token' => $response->toArray()['hydra:member'][0]['token']]); + $watchlist = $entityManager->getRepository(Watchlist::class)->findOneBy(['token' => $response->toArray()['hydra:member'][0]['token']]); $domain = (new Domain()) ->setLdhName((new UuidV4()).'.com') diff --git a/tests/State/WatchListUpdateProcessorTest.php b/tests/State/WatchlistUpdateProcessorTest.php similarity index 92% rename from tests/State/WatchListUpdateProcessorTest.php rename to tests/State/WatchlistUpdateProcessorTest.php index 1d68eb2..7d4c1a2 100644 --- a/tests/State/WatchListUpdateProcessorTest.php +++ b/tests/State/WatchlistUpdateProcessorTest.php @@ -4,14 +4,14 @@ namespace App\Tests\State; use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; use ApiPlatform\Symfony\Bundle\Test\Client; -use App\Entity\WatchList; +use App\Entity\Watchlist; use App\Factory\UserFactory; use App\Tests\AuthenticatedUserTrait; use App\Tests\Service\RDAPServiceTest; use PHPUnit\Framework\Attributes\DependsExternal; use Zenstruck\Foundry\Test\Factories; -final class WatchListUpdateProcessorTest extends ApiTestCase +final class WatchlistUpdateProcessorTest extends ApiTestCase { use Factories; use AuthenticatedUserTrait; @@ -22,7 +22,7 @@ final class WatchListUpdateProcessorTest extends ApiTestCase self::createUserAndWatchlist(); $this->assertResponseIsSuccessful(); $this->assertResponseStatusCodeSame(201); - $this->assertMatchesResourceItemJsonSchema(WatchList::class); + $this->assertMatchesResourceItemJsonSchema(Watchlist::class); } #[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')] @@ -48,7 +48,7 @@ final class WatchListUpdateProcessorTest extends ApiTestCase 'trackedEppStatus' => [], ]]); $this->assertResponseIsSuccessful(); - $this->assertMatchesResourceItemJsonSchema(WatchList::class); + $this->assertMatchesResourceItemJsonSchema(Watchlist::class); $data = $response->toArray(); $this->assertCount(2, $data['domains']); $this->assertCount(1, $data['trackedEvents']);