add other mails

This commit is contained in:
Baptiste Lemoine 2020-04-16 18:14:59 +02:00
parent f6da68997d
commit f40eb596b4
3 changed files with 52 additions and 1 deletions

View File

@ -115,7 +115,10 @@ class CommentController extends FramadateController {
$em->persist( $comment );
$em->flush();
$this->mail_service->sendCommentNotification($comment);
if($poll->getMailOnComment()){
$this->sendCommentNotificationAction($foundOwner, $comment);
}
return $this->json( [
'message' => 'you created a comment',

View File

@ -106,4 +106,46 @@ class FramadateController extends AbstractController {
return $this->sendMailWithVars( $config );
}
/**
* @param Owner $owner
* @param $comment
*
* @return int
* @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface
*/
public function sendCommentNotificationAction( Owner $owner, $comment ) {
$config = [
'owner' => $owner,
'comment' => $comment,
'poll' => $comment->getPoll(),
'title' => 'Framadate | Commentaire de "' . $owner->getPseudo() . '" - sondage ' . $comment->getPoll()->getTitle(),
'email_template' => 'emails/comment-notification.html.twig',
];
$this->sendMailWithVars( $config );
return 1;
}
/**
* @param Owner $owner
* @param $stackOfVotes
*
* @return int
* @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface
*/
public function sendVoteNotificationAction( Owner $owner, $stackOfVotes ) {
$config = [
'owner' => $owner,
'comment' => $stackOfVotes,
'poll' => $stackOfVotes->getPoll(),
'title' => 'Framadate | Vote de "' . $owner->getPseudo() . '" - sondage ' . $stackOfVotes->getPoll()->getTitle(),
'email_template' => 'emails/vote-notification.html.twig',
];
$this->sendMailWithVars( $config );
return 1;
}
}

View File

@ -119,6 +119,12 @@ class VoteController extends FramadateController {
$choices[] = $c->display();
}
if($poll->getMailOnVote()){
$this->sendVoteNotificationAction($stack->getOwner(), $stack);
}
return $this->json( [
'message' => 'you created a vote stack' . $precision,
'poll' => $poll,