From 436dddcc6a138972f07b97685767bbad200d3347 Mon Sep 17 00:00:00 2001
From: Camille Simiand <camille.simiand@tetras-libre.fr>
Date: Mon, 31 Jan 2022 10:37:47 +0100
Subject: [PATCH] Improve email message for editor

---
 src/Controller/CapsuleEditorController.php       | 4 +++-
 templates/capsule/editors/email_editor.html.twig | 3 +++
 translations/messages.en.yaml                    | 3 ++-
 translations/messages.fr.yaml                    | 3 ++-
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/Controller/CapsuleEditorController.php b/src/Controller/CapsuleEditorController.php
index 3fdc4dc..a10dc17 100644
--- a/src/Controller/CapsuleEditorController.php
+++ b/src/Controller/CapsuleEditorController.php
@@ -11,6 +11,7 @@ use App\Repository\CapsulePendingEditorRepository;
 use App\Repository\CapsuleRepository;
 use App\Repository\UserRepository;
 use Doctrine\ORM\EntityManagerInterface;
+use http\Env;
 use Symfony\Bridge\Twig\Mime\TemplatedEmail;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\HttpFoundation\Request;
@@ -188,7 +189,8 @@ class CapsuleEditorController extends AbstractController
             ->htmlTemplate('capsule/editors/email_editor.html.twig')
             ->context([
                 'user' => $current_user,
-                'capsule' => $capsule
+                'capsule' => $capsule,
+                'member_url_external' => $_ENV['MEMBER_URL_EXTERNAL']
             ]);
 
         $this->mailer->send($email);
diff --git a/templates/capsule/editors/email_editor.html.twig b/templates/capsule/editors/email_editor.html.twig
index c28c681..a4125b0 100644
--- a/templates/capsule/editors/email_editor.html.twig
+++ b/templates/capsule/editors/email_editor.html.twig
@@ -12,6 +12,9 @@
             <div class="col-6">
                 <p class="alert">
                     {{ 'editors.add.user.email.text'|trans({'%user_name%': user.getFullName(), '%capsule_name%': capsule.getName()}) }}
+                    <a href="{{ member_url_external }}{{ capsule.getEditionLink() }}">
+                        {{ editors.add.user.email.link }}
+                    </a>
                 </p>
 
                 <p>{{ 'general.greeting'|trans }}</p>
diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml
index 0ed1025..328bafb 100644
--- a/translations/messages.en.yaml
+++ b/translations/messages.en.yaml
@@ -133,4 +133,5 @@ editors:
         email:
           title: New capsule on your list
           text: You have been add by %user_name% as editor of the capsule "%capsule_name%".
-            You can now access and edit it. You will find the capsule in your capsule list.
\ No newline at end of file
+            You can now access and edit it. You will find the capsule in your capsule list.
+          link: Go to capsule edition page
diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml
index 15bad03..9c27b16 100644
--- a/translations/messages.fr.yaml
+++ b/translations/messages.fr.yaml
@@ -131,4 +131,5 @@ editors:
         email:
           title: Nouvelle capsule dans votre liste
           text: Vous avez été ajouté par %user_name% en tant qu'éditeur de la capsule "%capsule_name%".
-            Vous pouvez maintenant y accéder et l'éditer. Vous la retrouverez dans la liste de vos capsules.
\ No newline at end of file
+            Vous pouvez maintenant y accéder et l'éditer. Vous la retrouverez dans la liste de vos capsules.
+          link: Se rendre sur la page d'édition de la capsule
\ No newline at end of file
-- 
GitLab