Skip to content

Commit

Permalink
Make new emails configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
pingiun committed May 19, 2024
1 parent d3d7794 commit d3952a2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ parameters:
app.privacyPolicyUrl: '%env(PRIVACY_POLICY_URL)%'
app.listmonkUrl: '%env(string:LISTMONK_URL)%'
app.useMiddleName: '%env(bool:USE_MIDDLE_NAME)%'
app.sendFreshMemberEmailToBoard: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_BOARD)%'
app.sendFreshMemberEmailToContactPeople: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_CONTACT_PEOPLE)%'
router.request_context.scheme: '%env(SECURE_SCHEME)%'
asset.request_context.secure: true

Expand Down
29 changes: 27 additions & 2 deletions src/Controller/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ public function handleRedirect(Request $request, string $customerId): Response
$memberFullName = $membershipApplication->getFullName();
$memberFirstName = $membershipApplication->getFirstName();

$emailSender = $this->getParameter('app.noReplyAddress');
$organizationName = $this->getParameter('app.organizationEmail');
$noreplySender = $this->getParameter('app.noReplyAddress');
$emailSender = $this->getParameter('app.organizationEmail');
$organizationName = $this->getParameter('app.organizationName');
$message = (new Email())
->subject("Bedankt voor je aanmelding bij $organizationName!")
->to(new Address($memberEmail, $memberFullName))
Expand All @@ -200,6 +201,30 @@ public function handleRedirect(Request $request, string $customerId): Response
$this->renderView($templatePrefix . 'email/text/apply.txt.twig', ['memberFirstName' => $memberFirstName])
);
$this->mailer->send($message);

if ($this->getParameter('app.sendFreshMemberEmailToBoard')) {
$message = (new Email())
->subject("Er is een nieuw lid die geaccepteerd kan worden")
->to(new Address($emailSender, $organizationName))
->from(new Address($noreplySender, "De website"))
->text(
$this->renderView($templatePrefix . 'email/text/fresh_member.txt.twig', ['memberFullName' => $memberFullName, 'memberEmail' => $memberEmail])
);
$this->mailer->send($message);
}

if ($this->getParameter('app.sendFreshMemberEmailToContactPeople') && $membershipApplication->getPreferredDivision() !== null) {
$division = $membershipApplication->getPreferredDivision();
$message = (new Email())
->subject("Er is een nieuw lid die geaccepteerd kan worden")
->to(new Address($division->getEmail(), $division->getName()))
->from(new Address($noreplySender, "De website"))
->text(
$this->renderView($templatePrefix . 'email/text/fresh_member.txt.twig', ['memberFullName' => $memberFullName, 'memberEmail' => $memberEmail])
);
$this->mailer->send($message);
}

$membershipApplication->setHasSentInitialEmail(true);
$em = $this->getDoctrine()->getManager();
$em->persist($membershipApplication);
Expand Down
2 changes: 1 addition & 1 deletion templates/email/text/apply.txt.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Kameraadschappelijke groet,

{{ organisatienaam }}

{% endblock %}
{% endblock %}
16 changes: 16 additions & 0 deletions templates/email/text/fresh_member.txt.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends 'email/text/layout.txt.twig' %}
{% block content %}
Hoi bestuur of lokaal bestuur,

Er heeft net een lid zich aangemeld op de website. Je kan dit lid nu goedkeuren of weigeren op de website.

Dit is de informatie van het nieuwe lid:

{{ memberFullName }}
{{ memberEmail }}

Kameraadschappelijke groet,

de website

{% endblock %}

0 comments on commit d3952a2

Please sign in to comment.