mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
chore: rename WatchList to Watchlist
This commit is contained in:
@@ -63,7 +63,7 @@ export function UpdateWatchlistButton({watchlist, onUpdateWatchlist, connectors}
|
||||
}}
|
||||
connectors={connectors}
|
||||
isCreation={false}
|
||||
watchList={watchlist}
|
||||
watchlist={watchlist}
|
||||
/>
|
||||
</Drawer>
|
||||
</>
|
||||
|
||||
@@ -33,7 +33,7 @@ export function WatchlistForm({form, connectors, onFinish, isCreation}: {
|
||||
connectors: Array<Connector & { id: string }>
|
||||
onFinish: (values: { domains: string[], trackedEvents: string[], trackedEppStatus: string[], token: string }) => void
|
||||
isCreation: boolean,
|
||||
watchList?: Watchlist,
|
||||
watchlist?: Watchlist,
|
||||
}) {
|
||||
const rdapEventNameTranslated = rdapEventNameTranslation()
|
||||
const rdapEventDetailTranslated = rdapEventDetailTranslation()
|
||||
|
||||
@@ -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
|
||||
|
||||
79
migrations/Version20251025152900.php
Normal file
79
migrations/Version20251025152900.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20251025152900 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Rename WatchList to Watchlist';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
@@ -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!');
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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')
|
||||
@@ -61,10 +61,10 @@ class Connector
|
||||
private array $authData = [];
|
||||
|
||||
/**
|
||||
* @var Collection<int, WatchList>
|
||||
* @var Collection<int, Watchlist>
|
||||
*/
|
||||
#[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<int, WatchList>
|
||||
* @return Collection<int, Watchlist>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,10 +82,10 @@ class Domain
|
||||
private array $status = [];
|
||||
|
||||
/**
|
||||
* @var Collection<int, WatchList>
|
||||
* @var Collection<int, Watchlist>
|
||||
*/
|
||||
#[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<int, Nameserver>
|
||||
@@ -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<int, WatchList>
|
||||
* @return Collection<int, Watchlist>
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -66,10 +66,10 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
private ?string $password = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, WatchList>
|
||||
* @var Collection<int, Watchlist>
|
||||
*/
|
||||
#[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<int, Connector>
|
||||
@@ -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<int, WatchList>
|
||||
* @return Collection<int, Watchlist>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<int, Domain>
|
||||
*/
|
||||
#[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;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Message;
|
||||
final class OrderDomain
|
||||
{
|
||||
public function __construct(
|
||||
public string $watchListToken,
|
||||
public string $watchlistToken,
|
||||
public string $ldhName,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Message;
|
||||
|
||||
final class ProcessWatchListsTrigger
|
||||
final class ProcessWatchlistTrigger
|
||||
{
|
||||
/*
|
||||
* Add whatever properties and methods you need
|
||||
@@ -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,
|
||||
) {
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Message;
|
||||
final readonly class UpdateDomainsFromWatchlist
|
||||
{
|
||||
public function __construct(
|
||||
public string $watchListToken,
|
||||
public string $watchlistToken,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<WatchList>
|
||||
* @extends ServiceEntityRepository<Watchlist>
|
||||
*/
|
||||
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')
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
@@ -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'];
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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']);
|
||||
Reference in New Issue
Block a user