From dc3a585e5bd1b55f7d1c96e122928e41ec272a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 23 Feb 2026 15:49:39 +0000 Subject: [PATCH] Remove unused method `sendNotificationEmailsToAddressesEmails` from `NotificationMailer` --- .../unreleased/Feature-20260223-164835.yaml | 7 +++ .../Notification/Email/NotificationMailer.php | 44 +++---------------- ...il_non_system_notification_content.md.twig | 19 ++++---- ...l_non_system_notification_content.txt.twig | 14 ++++++ ...stem_notification_content_to_email.md.twig | 20 --------- ...email_notification_comment_persist.md.twig | 12 +++-- ...mail_notification_comment_persist.txt.twig | 14 ++++++ 7 files changed, 54 insertions(+), 76 deletions(-) create mode 100644 .changes/unreleased/Feature-20260223-164835.yaml create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content.txt.twig delete mode 100644 src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content_to_email.md.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Notification/email_notification_comment_persist.txt.twig diff --git a/.changes/unreleased/Feature-20260223-164835.yaml b/.changes/unreleased/Feature-20260223-164835.yaml new file mode 100644 index 000000000..07ffcc676 --- /dev/null +++ b/.changes/unreleased/Feature-20260223-164835.yaml @@ -0,0 +1,7 @@ +kind: Feature +body: Send email related to notification in both html and txt format, and render quote correctly +time: 2026-02-23T16:48:35.48244838+01:00 +custom: + Issue: "495" + MR: "967" + SchemaChange: No schema change diff --git a/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php b/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php index 1cb64ff4a..237cb178b 100644 --- a/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php +++ b/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php @@ -59,7 +59,8 @@ readonly class NotificationMailer $email ->to($dest->getEmail()) ->subject('Re: '.$comment->getNotification()->getTitle()) - ->textTemplate('@ChillMain/Notification/email_notification_comment_persist.md.twig') + ->textTemplate('@ChillMain/Notification/email_notification_comment_persist.txt.twig') + ->htmlTemplate('@ChillMain/Notification/email_notification_comment_persist.md.twig') ->context([ 'comment' => $comment, 'dest' => $dest, @@ -83,7 +84,6 @@ readonly class NotificationMailer public function postPersistNotification(Notification $notification, PostPersistEventArgs $eventArgs): void { $this->sendNotificationEmailsToAddressees($notification); - $this->sendNotificationEmailsToAddressesEmails($notification); } private function sendNotificationEmailsToAddressees(Notification $notification): void @@ -149,7 +149,8 @@ readonly class NotificationMailer } else { $email = new TemplatedEmail(); $email - ->textTemplate('@ChillMain/Notification/email_non_system_notification_content.md.twig') + ->textTemplate('@ChillMain/Notification/email_non_system_notification_content.txt.twig') + ->htmlTemplate('@ChillMain/Notification/email_non_system_notification_content.md.twig') ->context([ 'notification' => $notification, 'dest' => $addressee, @@ -186,7 +187,8 @@ readonly class NotificationMailer } else { $email = new TemplatedEmail(); $email - ->textTemplate('@ChillMain/Notification/email_non_system_notification_content.md.twig') + ->textTemplate('@ChillMain/Notification/email_non_system_notification_content.txt.twig') + ->htmlTemplate('@ChillMain/Notification/email_non_system_notification_content.md.twig') ->context([ 'notification' => $notification, 'dest' => $addressee, @@ -286,38 +288,4 @@ readonly class NotificationMailer throw $e; } } - - private function sendNotificationEmailsToAddressesEmails(Notification $notification): void - { - foreach ($notification->getAddresseeUserGroups() as $userGroup) { - - if (!$userGroup->hasEmail()) { - continue; - } - - $emailAddress = $userGroup->getEmail(); - - $email = new TemplatedEmail(); - $email - ->textTemplate('@ChillMain/Notification/email_non_system_notification_content_to_email.md.twig') - ->context([ - 'notification' => $notification, - 'dest' => $emailAddress, - ]); - - $email - ->subject($notification->getTitle()) - ->to($emailAddress); - - try { - $this->mailer->send($email); - } catch (TransportExceptionInterface $e) { - $this->logger->warning('[NotificationMailer] could not send an email notification', [ - 'to' => $emailAddress, - 'error_message' => $e->getMessage(), - 'error_trace' => $e->getTraceAsString(), - ]); - } - } - } } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content.md.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content.md.twig index 023f2901a..5c07e2ef7 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content.md.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content.md.twig @@ -1,20 +1,17 @@ +{% apply markdown_to_html %} {{ dest.label }}, {{ notification.sender.label }} a créé une notification pour vous: -> {{ notification.title }} -> -> -{%- for line in notification.message|split("\n") %} +**Titre de la notification**: {{ notification.title }} + +{% for line in notification.message|split("\n") %} > {{ line }} -{%- if not loop.last %} -> -{%- endif %} -{%- endfor %} +{% endfor %} -Vous pouvez visualiser la notification et y répondre ici: +[Vous pouvez visualiser la notification et y répondre ici.]({{ absolute_url(path('chill_main_notification_show', {'_locale': dest.locale, 'id': notification.id }, false)) }}) -{{ absolute_url(path('chill_main_notification_show', {'_locale': dest.locale, 'id': notification.id }, false)) }} +----- --- Le logiciel Chill +{% endapply %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content.txt.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content.txt.twig new file mode 100644 index 000000000..58f138322 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content.txt.twig @@ -0,0 +1,14 @@ +{{ dest.label }}, + +{{ notification.sender.label }} a créé une notification pour vous: + +Titre de la notification: {{ notification.title }} + +{% for line in notification.message|split("\n") %} +> {{ line|raw }} +{% endfor %} + +Vous pouvez visualiser la notification et y répondre ici: {{ absolute_url(path('chill_main_notification_show', {'_locale': dest.locale, 'id': notification.id }, false)) }}. + +-- +Le logiciel Chill diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content_to_email.md.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content_to_email.md.twig deleted file mode 100644 index 9a32f0c15..000000000 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/email_non_system_notification_content_to_email.md.twig +++ /dev/null @@ -1,20 +0,0 @@ -{{ dest }}, - -{{ notification.sender.label }} a créé une notification pour vous: - -> {{ notification.title }} -> -> -{%- for line in notification.message|split("\n") %} -> {{ line }} -{%- if not loop.last %} -> -{%- endif %} -{%- endfor %} - -Vous pouvez cliquer sur ce lien pour obtenir un accès permanent à la notification: - -{{ absolute_url(path('chill_main_notification_grant_access_by_access_key', {'_locale': 'fr', 'id': notification.id, 'accessKey': notification.accessKey, 'email': dest})) }} - --- -Le logiciel Chill diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/email_notification_comment_persist.md.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/email_notification_comment_persist.md.twig index e7e212492..176484d9f 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/email_notification_comment_persist.md.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/email_notification_comment_persist.md.twig @@ -1,3 +1,4 @@ +{% apply markdown_to_html %} {{ dest.label }}, {{ comment.createdBy.label }} a créé un commentaire sur la notification "{{ comment.notification.title }}". @@ -6,14 +7,11 @@ Commentaire: {% for line in comment.content|split("\n") %} > {{ line }} -{%- if not loop.last %} -> -{%- endif %} -{%- endfor %} +{% endfor %} -Vous pouvez visualiser la notification et y répondre ici: +[Vous pouvez visualiser la notification et y répondre ici.]({{ absolute_url(path('chill_main_notification_show', {'_locale': dest.locale, 'id': comment.notification.id }, false)) }}) -{{ absolute_url(path('chill_main_notification_show', {'_locale': dest.locale, 'id': comment.notification.id }, false)) }} +---- --- Le logiciel Chill +{% endapply %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/email_notification_comment_persist.txt.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/email_notification_comment_persist.txt.twig new file mode 100644 index 000000000..952c38662 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/email_notification_comment_persist.txt.twig @@ -0,0 +1,14 @@ +{{ dest.label }}, + +{{ comment.createdBy.label }} a créé un commentaire sur la notification "{{ comment.notification.title }}". + +Commentaire: + +{% for line in comment.content|split("\n") %} +> {{ line }} +{%- endfor %} + +Vous pouvez visualiser la notification et y répondre ici: {{ absolute_url(path('chill_main_notification_show', {'_locale': dest.locale, 'id': comment.notification.id }, false)) }} + +-- +Le logiciel Chill