From f6da68997db1e661a9c58ee0983056b55c553273 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Thu, 16 Apr 2020 18:06:43 +0200 Subject: [PATCH] :zap: create a poll sends a mail to owner --- src/Controller/FramadateController.php | 21 +++++++++++++++++++++ src/Controller/PollController.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Controller/FramadateController.php b/src/Controller/FramadateController.php index 3b067f7..4faf3ac 100644 --- a/src/Controller/FramadateController.php +++ b/src/Controller/FramadateController.php @@ -85,4 +85,25 @@ class FramadateController extends AbstractController { return 1; } + + /** + * @param Owner $foundOwner + * @param Poll|null $poll + * + * @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface + */ + public function sendCreationMailAction( Owner $foundOwner, Poll $poll = null ) { + + // anti spam , limit to every minute TODO + + $config = [ + 'owner' => $foundOwner, + 'from' => 'ne-pas-repondre@framadate-api.cipherbliss.com', + 'poll' => $poll, + 'title' => 'Création de sondage - ' . ( $poll ? $poll->getTitle() : $poll ), + 'email_template' => 'emails/creation-mail.html.twig', + ]; + + return $this->sendMailWithVars( $config ); + } } diff --git a/src/Controller/PollController.php b/src/Controller/PollController.php index 3098095..751498c 100644 --- a/src/Controller/PollController.php +++ b/src/Controller/PollController.php @@ -227,7 +227,7 @@ class PollController extends FramadateController { $precision = 'from an existing user : ' . $foundOwner->getEmail(); } - $this->mail_service->sendCreationMailAction( $foundOwner, $newpoll ); + $this->sendCreationMailAction( $foundOwner, $newpoll ); return $this->json( [ 'message' => 'you created a poll ' . $precision,