-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace swiftmailer with symfony/mailer (#391)
* feat: replace swift_mailer with symfony/mailer * fix passwordreset-test * fix typo * remove swiftmailer-bundle * fix tests * fiix test
- Loading branch information
Showing
23 changed files
with
307 additions
and
466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
use App\Mailer\MailingInterface; | ||
use App\Service\AdmissionNotifier; | ||
use App\Service\UserRegistration; | ||
use Symfony\Bridge\Twig\Mime\TemplatedEmail; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Twig\Environment; | ||
|
||
|
@@ -34,7 +35,7 @@ public static function getSubscribedEvents(): array | |
]; | ||
} | ||
|
||
public function createAdmissionSubscriber(ApplicationCreatedEvent $event) | ||
public function createAdmissionSubscriber(ApplicationCreatedEvent $event): void | ||
{ | ||
$application = $event->getApplication(); | ||
$department = $application->getUser()->getDepartment(); | ||
|
@@ -46,7 +47,7 @@ public function createAdmissionSubscriber(ApplicationCreatedEvent $event) | |
} | ||
} | ||
|
||
public function sendConfirmationMail(ApplicationCreatedEvent $event) | ||
public function sendConfirmationMail(ApplicationCreatedEvent $event): void | ||
{ | ||
$application = $event->getApplication(); | ||
$user = $application->getUser(); | ||
|
@@ -61,20 +62,17 @@ public function sendConfirmationMail(ApplicationCreatedEvent $event) | |
} | ||
|
||
// Send a confirmation email with a copy of the application | ||
$emailMessage = (new \Swift_Message()) | ||
->setSubject('Søknad - Vektorassistent') | ||
->setReplyTo($application->getDepartment()->getEmail()) | ||
->setTo($application->getUser()->getEmail()) | ||
->setBody( | ||
$this->twig->render( | ||
$template, | ||
[ | ||
'application' => $application, | ||
'newUserCode' => $newUserCode, | ||
] | ||
), | ||
'text/html' | ||
); | ||
$emailMessage = (new TemplatedEmail()) | ||
->subject('Søknad - Vektorassistent') | ||
->replyTo($application->getDepartment()->getEmail()) | ||
->to($application->getUser()->getEmail()) | ||
->from('[email protected]') | ||
->htmlTemplate($template) | ||
->context([ | ||
'application' => $application, | ||
'newUserCode' => $newUserCode, | ||
]); | ||
|
||
$this->mailer->send($emailMessage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,10 @@ | |
use App\Sms\Sms; | ||
use App\Sms\SmsSenderInterface; | ||
use Psr\Log\LoggerInterface; | ||
use Symfony\Bridge\Twig\Mime\TemplatedEmail; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\Mime\Address; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Twig\Environment; | ||
|
||
|
@@ -55,26 +57,26 @@ public static function getSubscribedEvents(): array | |
]; | ||
} | ||
|
||
public function sendInterviewReceipt(InterviewConductedEvent $event) | ||
public function sendInterviewReceipt(InterviewConductedEvent $event): void | ||
{ | ||
$application = $event->getApplication(); | ||
$interviewer = $application->getInterview()->getInterviewer(); | ||
|
||
// Send email to the interviewee with a summary of the interview | ||
$emailMessage = (new \Swift_Message()) | ||
->setSubject('Vektorprogrammet intervju') | ||
->setReplyTo([$interviewer->getDepartment()->getEmail() => 'Vektorprogrammet']) | ||
->setTo($application->getUser()->getEmail()) | ||
->setReplyTo($interviewer->getEmail()) | ||
->setBody($this->twig->render('interview/interview_summary_email.html.twig', [ | ||
$emailMessage = (new TemplatedEmail()) | ||
->subject('Vektorprogrammet intervju') | ||
->replyTo(new Address($interviewer->getDepartment()->getEmail(), 'Vektorprogrammet')) | ||
->to($application->getUser()->getEmail()) | ||
->from(new Address('[email protected]', 'Vektorprogrammet.no')) | ||
->htmlTemplate('interview/interview_summary_email.html.twig') | ||
->context([ | ||
'application' => $application, | ||
'interviewer' => $interviewer, | ||
])) | ||
->setContentType('text/html'); | ||
]); | ||
$this->mailer->send($emailMessage); | ||
} | ||
|
||
public function addFlashMessage(InterviewConductedEvent $event) | ||
public function addFlashMessage(InterviewConductedEvent $event): void | ||
{ | ||
$user = $event->getApplication()->getUser(); | ||
$message = "Intervjuet med $user ble lagret. En kvittering med et sammendrag av | ||
|
@@ -83,7 +85,7 @@ public function addFlashMessage(InterviewConductedEvent $event) | |
$this->requestStack->getSession()->getFlashBag()->add('success', $message); | ||
} | ||
|
||
public function logEvent(InterviewConductedEvent $event) | ||
public function logEvent(InterviewConductedEvent $event): void | ||
{ | ||
$application = $event->getApplication(); | ||
|
||
|
@@ -94,7 +96,7 @@ public function logEvent(InterviewConductedEvent $event) | |
$this->logger->info("$department: New interview with $interviewee registered"); | ||
} | ||
|
||
public function sendSlackNotifications(InterviewConductedEvent $event) | ||
public function sendSlackNotifications(InterviewConductedEvent $event): void | ||
{ | ||
$application = $event->getApplication(); | ||
|
||
|
@@ -116,12 +118,12 @@ public function sendSlackNotifications(InterviewConductedEvent $event) | |
} | ||
} | ||
|
||
public function sendScheduleEmail(InterviewEvent $event) | ||
public function sendScheduleEmail(InterviewEvent $event): void | ||
{ | ||
$this->interviewManager->sendScheduleEmail($event->getInterview(), $event->getData()); | ||
} | ||
|
||
public function sendScheduleSms(InterviewEvent $event) | ||
public function sendScheduleSms(InterviewEvent $event): void | ||
{ | ||
$interview = $event->getInterview(); | ||
$data = $event->getData(); | ||
|
@@ -166,17 +168,18 @@ public function sendScheduleSms(InterviewEvent $event) | |
$this->smsSender->send($sms); | ||
} | ||
|
||
public function sendCoAssignedEmail(InterviewEvent $event) | ||
public function sendCoAssignedEmail(InterviewEvent $event): void | ||
{ | ||
$interview = $event->getInterview(); | ||
$emailMessage = (new \Swift_Message()) | ||
->setSubject('Vektorprogrammet intervju') | ||
->setFrom(['[email protected]' => 'Vektorprogrammet']) | ||
->setTo($interview->getInterviewer()->getEmail()) | ||
->setReplyTo($interview->getCoInterviewer()->getEmail()) | ||
->setBody($this->twig->render('interview/co_interviewer_email.html.twig', [ | ||
$emailMessage = (new TemplatedEmail()) | ||
->subject('Vektorprogrammet intervju') | ||
->from(new Address('[email protected]', 'Vektorprogrammet')) | ||
->to($interview->getInterviewer()->getEmail()) | ||
->replyTo($interview->getCoInterviewer()->getEmail()) | ||
->htmlTemplate('interview/co_interviewer_email.html.twig') | ||
->context([ | ||
'interview' => $interview, | ||
])); | ||
]); | ||
$this->mailer->send($emailMessage); | ||
} | ||
} |
Oops, something went wrong.