mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 02:05:36 +00:00
feat: add domain_deleted notif
This commit is contained in:
parent
0761e7dce8
commit
e97cb95637
@ -7,8 +7,10 @@ use App\Entity\WatchList;
|
||||
use App\Message\OrderDomain;
|
||||
use App\Message\SendDomainEventNotif;
|
||||
use App\Message\UpdateDomainsFromWatchlist;
|
||||
use App\Notifier\DomainDeletedNotification;
|
||||
use App\Notifier\DomainUpdateErrorNotification;
|
||||
use App\Repository\WatchListRepository;
|
||||
use App\Service\ChatNotificationService;
|
||||
use App\Service\RDAPService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@ -31,6 +33,7 @@ final readonly class UpdateDomainsFromWatchlistHandler
|
||||
|
||||
public function __construct(
|
||||
private RDAPService $RDAPService,
|
||||
private ChatNotificationService $chatNotificationService,
|
||||
private MailerInterface $mailer,
|
||||
string $mailerSenderEmail,
|
||||
string $mailerSenderName,
|
||||
@ -80,6 +83,10 @@ final readonly class UpdateDomainsFromWatchlistHandler
|
||||
$this->RDAPService->registerDomain($domain->getLdhName());
|
||||
$this->bus->dispatch(new SendDomainEventNotif($watchList->getToken(), $domain->getLdhName(), $updatedAt));
|
||||
} catch (NotFoundHttpException) {
|
||||
$notification = (new DomainDeletedNotification($this->sender, $domain));
|
||||
$this->mailer->send($notification->asEmailMessage(new Recipient($watchList->getUser()->getEmail()))->getMessage());
|
||||
$this->chatNotificationService->sendChatNotification($watchList, $notification);
|
||||
|
||||
if (null !== $watchList->getConnector()) {
|
||||
/*
|
||||
* If the domain name no longer appears in the WHOIS AND a connector is associated with this Watchlist,
|
||||
|
||||
58
src/Notifier/DomainDeletedNotification.php
Normal file
58
src/Notifier/DomainDeletedNotification.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifier;
|
||||
|
||||
use App\Entity\Domain;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Notifier\Message\ChatMessage;
|
||||
use Symfony\Component\Notifier\Message\EmailMessage;
|
||||
use Symfony\Component\Notifier\Message\PushMessage;
|
||||
use Symfony\Component\Notifier\Notification\Notification;
|
||||
use Symfony\Component\Notifier\Recipient\EmailRecipientInterface;
|
||||
use Symfony\Component\Notifier\Recipient\RecipientInterface;
|
||||
|
||||
class DomainDeletedNotification extends DomainWatchdogNotification
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Address $sender,
|
||||
private readonly Domain $domain,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function asChatMessage(?RecipientInterface $recipient = null, ?string $transport = null): ?ChatMessage
|
||||
{
|
||||
$ldhName = $this->domain->getLdhName();
|
||||
$this->subject("Error: Domain Deleted $ldhName")
|
||||
->content("Domain name $ldhName has been deleted from WHOIS.")
|
||||
->importance(Notification::IMPORTANCE_URGENT);
|
||||
|
||||
return ChatMessage::fromNotification($this);
|
||||
}
|
||||
|
||||
public function asPushMessage(?RecipientInterface $recipient = null, ?string $transport = null): ?PushMessage
|
||||
{
|
||||
$ldhName = $this->domain->getLdhName();
|
||||
$this->subject("Error: Domain Deleted $ldhName")
|
||||
->content("Domain name $ldhName has been deleted from WHOIS.")
|
||||
->importance(Notification::IMPORTANCE_URGENT);
|
||||
|
||||
return PushMessage::fromNotification($this);
|
||||
}
|
||||
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
||||
{
|
||||
$ldhName = $this->domain->getLdhName();
|
||||
|
||||
return new EmailMessage((new TemplatedEmail())
|
||||
->from($this->sender)
|
||||
->to($recipient->getEmail())
|
||||
->subject("Domain name $ldhName has been removed from WHOIS")
|
||||
->htmlTemplate('emails/errors/domain_deleted.html.twig')
|
||||
->locale('en')
|
||||
->context([
|
||||
'domain' => $this->domain,
|
||||
]));
|
||||
}
|
||||
}
|
||||
@ -43,10 +43,12 @@ class DomainOrderErrorNotification extends DomainWatchdogNotification
|
||||
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
||||
{
|
||||
$ldhName = $this->domain->getLdhName();
|
||||
|
||||
return new EmailMessage((new TemplatedEmail())
|
||||
->from($this->sender)
|
||||
->to($recipient->getEmail())
|
||||
->subject('An error occurred while ordering a domain name')
|
||||
->subject("Domain name $ldhName tried to be purchased")
|
||||
->htmlTemplate('emails/errors/domain_order.html.twig')
|
||||
->locale('en')
|
||||
->context([
|
||||
|
||||
@ -48,11 +48,13 @@ class DomainOrderNotification extends DomainWatchdogNotification
|
||||
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
||||
{
|
||||
$ldhName = $this->domain->getLdhName();
|
||||
|
||||
return new EmailMessage((new TemplatedEmail())
|
||||
->from($this->sender)
|
||||
->to($recipient->getEmail())
|
||||
->priority(Email::PRIORITY_HIGHEST)
|
||||
->subject('A domain name has been ordered')
|
||||
->subject("Domain name $ldhName has just been purchased")
|
||||
->htmlTemplate('emails/success/domain_ordered.html.twig')
|
||||
->locale('en')
|
||||
->context([
|
||||
|
||||
@ -43,10 +43,12 @@ class DomainUpdateErrorNotification extends DomainWatchdogNotification
|
||||
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
||||
{
|
||||
$ldhName = $this->domain->getLdhName();
|
||||
|
||||
return new EmailMessage((new TemplatedEmail())
|
||||
->from($this->sender)
|
||||
->to($recipient->getEmail())
|
||||
->subject('An error occurred while updating a domain name')
|
||||
->subject("Domain name $ldhName tried to be updated")
|
||||
->htmlTemplate('emails/errors/domain_update.html.twig')
|
||||
->locale('en')
|
||||
->context([
|
||||
|
||||
@ -46,11 +46,13 @@ class DomainUpdateNotification extends DomainWatchdogNotification
|
||||
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
||||
{
|
||||
$ldhName = $this->domainEvent->getDomain()->getLdhName();
|
||||
|
||||
return new EmailMessage((new TemplatedEmail())
|
||||
->from($this->sender)
|
||||
->to($recipient->getEmail())
|
||||
->priority(Email::PRIORITY_HIGHEST)
|
||||
->subject('A domain name has been changed')
|
||||
->subject("Domain name $ldhName information has been updated")
|
||||
->htmlTemplate('emails/success/domain_updated.html.twig')
|
||||
->locale('en')
|
||||
->context([
|
||||
|
||||
15
templates/emails/success/domain_deleted.html.twig
Normal file
15
templates/emails/success/domain_deleted.html.twig
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends "emails/base.html.twig" %}
|
||||
|
||||
{% set email_color = '#0056b3' %}
|
||||
{% set title = 'Domain Watchdog Alert' %}
|
||||
{% block content %}
|
||||
<p>Hello, <br/>
|
||||
We are pleased to inform you that a domain name in your watchlist has been detected as deleted from the WHOIS database.<br/>
|
||||
<strong>Domain name:</strong> {{ domain.ldhName }}<br/>
|
||||
<strong>Detection Date:</strong> {{ domain.updatedAt | date("c") }}<br/>
|
||||
<br/>
|
||||
This domain has been identified as deleted and is potentially available for registration until it is registered by another party.<br/><br/>
|
||||
Thank you for your understanding,<br/>
|
||||
Sincerely,<br/>
|
||||
</p>
|
||||
{% endblock %}
|
||||
Loading…
x
Reference in New Issue
Block a user