From 5184f2c1908ac8b911c5113c11a616a3a702891b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Mon, 28 Apr 2025 17:50:13 +0200 Subject: [PATCH] feat: add In-Reply-To and References headers to email --- src/Notifier/DomainDeletedNotification.php | 10 ++++++++-- src/Notifier/DomainOrderErrorNotification.php | 10 ++++++++-- src/Notifier/DomainOrderNotification.php | 10 ++++++++-- src/Notifier/DomainUpdateErrorNotification.php | 10 ++++++++-- src/Notifier/DomainUpdateNotification.php | 10 ++++++++-- ...redentials.twig => connector_credentials.html.twig} | 0 .../{success => errors}/domain_deleted.html.twig | 2 +- 7 files changed, 41 insertions(+), 11 deletions(-) rename templates/emails/errors/{connector_credentials.twig => connector_credentials.html.twig} (100%) rename templates/emails/{success => errors}/domain_deleted.html.twig (94%) diff --git a/src/Notifier/DomainDeletedNotification.php b/src/Notifier/DomainDeletedNotification.php index 84da9ea..be622f2 100644 --- a/src/Notifier/DomainDeletedNotification.php +++ b/src/Notifier/DomainDeletedNotification.php @@ -46,7 +46,7 @@ class DomainDeletedNotification extends DomainWatchdogNotification { $ldhName = $this->domain->getLdhName(); - return new EmailMessage((new TemplatedEmail()) + $email = (new TemplatedEmail()) ->from($this->sender) ->to($recipient->getEmail()) ->priority(Email::PRIORITY_HIGHEST) @@ -55,6 +55,12 @@ class DomainDeletedNotification extends DomainWatchdogNotification ->locale('en') ->context([ 'domain' => $this->domain, - ])); + ]); + + $email->getHeaders() + ->addHeader('In-Reply-To', "<$ldhName+updated@domain-watchdog>") + ->addHeader('References', "<$ldhName+updated@domain-watchdog>"); + + return new EmailMessage($email); } } diff --git a/src/Notifier/DomainOrderErrorNotification.php b/src/Notifier/DomainOrderErrorNotification.php index 2e0b5c9..902f8d6 100644 --- a/src/Notifier/DomainOrderErrorNotification.php +++ b/src/Notifier/DomainOrderErrorNotification.php @@ -46,7 +46,7 @@ class DomainOrderErrorNotification extends DomainWatchdogNotification { $ldhName = $this->domain->getLdhName(); - return new EmailMessage((new TemplatedEmail()) + $email = (new TemplatedEmail()) ->from($this->sender) ->to($recipient->getEmail()) ->priority(Email::PRIORITY_HIGH) @@ -55,6 +55,12 @@ class DomainOrderErrorNotification extends DomainWatchdogNotification ->locale('en') ->context([ 'domain' => $this->domain, - ])); + ]); + + $email->getHeaders() + ->addTextHeader('In-Reply-To', "<$ldhName+order-error@domain-watchdog>") + ->addTextHeader('References', "<$ldhName+order-error@domain-watchdog>"); + + return new EmailMessage($email); } } diff --git a/src/Notifier/DomainOrderNotification.php b/src/Notifier/DomainOrderNotification.php index 8ee51ee..67f7d6f 100644 --- a/src/Notifier/DomainOrderNotification.php +++ b/src/Notifier/DomainOrderNotification.php @@ -50,7 +50,7 @@ class DomainOrderNotification extends DomainWatchdogNotification { $ldhName = $this->domain->getLdhName(); - return new EmailMessage((new TemplatedEmail()) + $email = (new TemplatedEmail()) ->from($this->sender) ->to($recipient->getEmail()) ->priority(Email::PRIORITY_HIGHEST) @@ -60,6 +60,12 @@ class DomainOrderNotification extends DomainWatchdogNotification ->context([ 'domain' => $this->domain, 'provider' => $this->connector->getProvider()->value, - ])); + ]); + + $email->getHeaders() + ->addTextHeader('In-Reply-To', "<$ldhName+ordered@domain-watchdog>") + ->addTextHeader('References', "<$ldhName+ordered@domain-watchdog>"); + + return new EmailMessage($email); } } diff --git a/src/Notifier/DomainUpdateErrorNotification.php b/src/Notifier/DomainUpdateErrorNotification.php index ab9cf96..78a70d0 100644 --- a/src/Notifier/DomainUpdateErrorNotification.php +++ b/src/Notifier/DomainUpdateErrorNotification.php @@ -46,7 +46,7 @@ class DomainUpdateErrorNotification extends DomainWatchdogNotification { $ldhName = $this->domain->getLdhName(); - return new EmailMessage((new TemplatedEmail()) + $email = (new TemplatedEmail()) ->from($this->sender) ->to($recipient->getEmail()) ->priority(Email::PRIORITY_NORMAL) @@ -55,6 +55,12 @@ class DomainUpdateErrorNotification extends DomainWatchdogNotification ->locale('en') ->context([ 'domain' => $this->domain, - ])); + ]); + + $email->getHeaders() + ->addTextHeader('In-Reply-To', "<$ldhName+update-error@domain-watchdog>") + ->addTextHeader('References', "<$ldhName+update-error@domain-watchdog>"); + + return new EmailMessage($email); } } diff --git a/src/Notifier/DomainUpdateNotification.php b/src/Notifier/DomainUpdateNotification.php index 37134b7..ff92480 100644 --- a/src/Notifier/DomainUpdateNotification.php +++ b/src/Notifier/DomainUpdateNotification.php @@ -48,7 +48,7 @@ class DomainUpdateNotification extends DomainWatchdogNotification { $ldhName = $this->domainEvent->getDomain()->getLdhName(); - return new EmailMessage((new TemplatedEmail()) + $email = (new TemplatedEmail()) ->from($this->sender) ->to($recipient->getEmail()) ->priority(Email::PRIORITY_HIGH) @@ -57,6 +57,12 @@ class DomainUpdateNotification extends DomainWatchdogNotification ->locale('en') ->context([ 'event' => $this->domainEvent, - ])); + ]); + + $email->getHeaders() + ->addTextHeader('In-Reply-To', "<$ldhName+updated@domain-watchdog>") + ->addTextHeader('References', "<$ldhName+updated@domain-watchdog>"); + + return new EmailMessage($email); } } diff --git a/templates/emails/errors/connector_credentials.twig b/templates/emails/errors/connector_credentials.html.twig similarity index 100% rename from templates/emails/errors/connector_credentials.twig rename to templates/emails/errors/connector_credentials.html.twig diff --git a/templates/emails/success/domain_deleted.html.twig b/templates/emails/errors/domain_deleted.html.twig similarity index 94% rename from templates/emails/success/domain_deleted.html.twig rename to templates/emails/errors/domain_deleted.html.twig index 0f93b5c..5113a06 100644 --- a/templates/emails/success/domain_deleted.html.twig +++ b/templates/emails/errors/domain_deleted.html.twig @@ -1,4 +1,4 @@ -{% extends "emails/base.html.twig" %} +{% extends "../base.html.twig" %} {% set email_color = '#0056b3' %} {% set title = 'Domain Watchdog Alert' %}