mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 09:45:29 +00:00
feat: add sendEmailDomainOrderError
This commit is contained in:
parent
33f531a5bf
commit
3a9f22318f
@ -21,6 +21,7 @@ use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
||||
use Symfony\Component\Mime\Email;
|
||||
use Throwable;
|
||||
|
||||
#[AsMessageHandler]
|
||||
final readonly class ProcessDomainTriggerHandler
|
||||
@ -54,14 +55,15 @@ final readonly class ProcessDomainTriggerHandler
|
||||
|
||||
if ($watchListTrigger->getAction() === TriggerAction::BuyDomain) {
|
||||
|
||||
try {
|
||||
if ($watchListTrigger->getConnector() === null) throw new Exception('Connector is missing');
|
||||
|
||||
$connector = $watchListTrigger->getConnector();
|
||||
|
||||
if ($connector->getProvider() === ConnectorProvider::OVH) {
|
||||
$ovh = new OVHConnector($connector->getAuthData());
|
||||
$isDebug = $this->kernel->isDebug();
|
||||
|
||||
|
||||
$ovh->orderDomain(
|
||||
$domain,
|
||||
true,
|
||||
@ -70,8 +72,10 @@ final readonly class ProcessDomainTriggerHandler
|
||||
$isDebug
|
||||
);
|
||||
$this->sendEmailDomainOrdered($domain, $connector, $watchList->getUser());
|
||||
|
||||
} else throw new Exception("Unknown provider");
|
||||
} catch (Throwable) {
|
||||
$this->sendEmailDomainOrderError($domain, $watchList->getUser());
|
||||
}
|
||||
}
|
||||
|
||||
/** @var DomainEvent $event */
|
||||
@ -103,6 +107,24 @@ final readonly class ProcessDomainTriggerHandler
|
||||
$this->mailer->send($email);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
private function sendEmailDomainOrderError(Domain $domain, User $user): void
|
||||
{
|
||||
$email = (new TemplatedEmail())
|
||||
->from($this->mailerSenderEmail)
|
||||
->to($user->getEmail())
|
||||
->subject('An error occurred while ordering a domain name')
|
||||
->htmlTemplate('emails/errors/domain_order.html.twig')
|
||||
->locale('en')
|
||||
->context([
|
||||
"domain" => $domain
|
||||
]);
|
||||
|
||||
$this->mailer->send($email);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
|
||||
77
templates/emails/errors/domain_order.html.twig
Normal file
77
templates/emails/errors/domain_order.html.twig
Normal file
@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 24px;
|
||||
color: #d9534f;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.content p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
text-align: center;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
ul li {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
<title>Domain Watchdog Error</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>Domain Watchdog Error</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Hello,</p>
|
||||
<p>We would like to inform you that an error occurred while ordering the following domain name:</p>
|
||||
<p><strong>Domain name:</strong> {{ domain.ldhName }}</p>
|
||||
<p>Here are some possible explanations:</p>
|
||||
<ul>
|
||||
<li>The Connector configuration you provided is no longer valid.</li>
|
||||
<li>It is likely that the domain is no longer available for registration.</li>
|
||||
<li>A temporary interruption is affecting the registration of this domain name.</li>
|
||||
</ul>
|
||||
<p>Thank you for your understanding,</p>
|
||||
<p>Sincerely,</p>
|
||||
<p>Domain Watchdog</p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p>© Domain Watchdog</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user