fix: a push notification is not chat

This commit is contained in:
Maël Gangloff
2024-08-27 21:44:42 +02:00
parent 4b0148fe49
commit 83a97b429b
7 changed files with 94 additions and 8 deletions

View File

@@ -7,13 +7,15 @@ 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\ChatNotificationInterface;
use Symfony\Component\Notifier\Notification\EmailNotificationInterface;
use Symfony\Component\Notifier\Notification\Notification;
use Symfony\Component\Notifier\Notification\PushNotificationInterface;
use Symfony\Component\Notifier\Recipient\EmailRecipientInterface;
use Symfony\Component\Notifier\Recipient\RecipientInterface;
class DomainUpdateErrorNotification extends Notification implements ChatNotificationInterface, EmailNotificationInterface
class DomainUpdateErrorNotification extends Notification implements ChatNotificationInterface, EmailNotificationInterface, PushNotificationInterface
{
public function __construct(
private readonly Address $sender,
@@ -32,6 +34,16 @@ class DomainUpdateErrorNotification extends Notification implements ChatNotifica
return ChatMessage::fromNotification($this);
}
public function asPushMessage(?RecipientInterface $recipient = null, ?string $transport = null): ?PushMessage
{
$ldhName = $this->domain->getLdhName();
$this->subject("Error: Domain Update $ldhName")
->content("Domain name $ldhName tried to be updated. The attempt failed.")
->importance(Notification::IMPORTANCE_MEDIUM);
return PushMessage::fromNotification($this);
}
public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): EmailMessage
{
return new EmailMessage((new TemplatedEmail())