Skip to content

Commit

Permalink
Don't send email if template is not active
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jul 3, 2024
1 parent 437c9b3 commit c85fbbc
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions lemarche/conversations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def __str__(self):

@property
def get_template_id(self):
if self.is_active and self.source and self.code:
if self.source and self.code:
if self.source == conversation_constants.SOURCE_MAILJET:
return self.mailjet_id
elif self.source == conversation_constants.SOURCE_BREVO:
Expand All @@ -263,23 +263,24 @@ def send_transactional_email(
from_email=settings.DEFAULT_FROM_EMAIL,
from_name=settings.DEFAULT_FROM_NAME,
):
if self.source == conversation_constants.SOURCE_MAILJET:
api_mailjet.send_transactional_email_with_template(
template_id=self.get_template_id,
recipient_email=recipient_email,
recipient_name=recipient_name,
variables=variables,
subject=subject,
from_email=from_email,
from_name=from_name,
)
elif self.source == conversation_constants.SOURCE_BREVO:
api_brevo.send_transactional_email_with_template(
template_id=self.get_template_id,
recipient_email=recipient_email,
recipient_name=recipient_name,
variables=variables,
subject=subject,
from_email=from_email,
from_name=from_name,
)
if self.is_active:
if self.source == conversation_constants.SOURCE_MAILJET:
api_mailjet.send_transactional_email_with_template(
template_id=self.get_template_id,
recipient_email=recipient_email,
recipient_name=recipient_name,
variables=variables,
subject=subject,
from_email=from_email,
from_name=from_name,
)
elif self.source == conversation_constants.SOURCE_BREVO:
api_brevo.send_transactional_email_with_template(
template_id=self.get_template_id,
recipient_email=recipient_email,
recipient_name=recipient_name,
variables=variables,
subject=subject,
from_email=from_email,
from_name=from_name,
)

0 comments on commit c85fbbc

Please sign in to comment.