Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
added reply_to to remaining tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
irfanuddinahmad committed May 25, 2021
1 parent 362b429 commit ec1e2ff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
18 changes: 12 additions & 6 deletions ecommerce_worker/email/v1/braze/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def send_offer_assignment_email_via_braze(self, user_email, offer_assignment_id, subject, email_body, sender_alias,
site_code):
reply_to, site_code):
"""
Sends the offer assignment email via Braze.
Expand All @@ -23,6 +23,7 @@ def send_offer_assignment_email_via_braze(self, user_email, offer_assignment_id,
subject (str): Email subject.
email_body (str): The body of the email.
sender_alias (str): Enterprise Customer sender alias used as From Name.
reply_to (str): Enterprise Customer reply to address for email reply
site_code (str): Identifier of the site sending the email.
base_enterprise_url (str): Url for the enterprise learner portal.
"""
Expand All @@ -34,7 +35,8 @@ def send_offer_assignment_email_via_braze(self, user_email, offer_assignment_id,
email_ids=user_emails,
subject=subject,
body=email_body,
sender_alias=sender_alias
sender_alias=sender_alias,
reply_to=reply_to
)
if response and response['success']:
dispatch_id = response['dispatch_id']
Expand All @@ -60,7 +62,7 @@ def send_offer_assignment_email_via_braze(self, user_email, offer_assignment_id,
)


def send_offer_update_email_via_braze(self, user_email, subject, email_body, sender_alias, site_code):
def send_offer_update_email_via_braze(self, user_email, subject, email_body, sender_alias, reply_to, site_code):
"""
Sends the offer emails after assignment via braze, either for revoking or reminding.
Expand All @@ -71,6 +73,7 @@ def send_offer_update_email_via_braze(self, user_email, subject, email_body, sen
email_body (str): The body of the email.
site_code (str): Identifier of the site sending the email.
sender_alias (str): Enterprise Customer sender alias used as From Name.
reply_to (str): Enterprise Customer reply to address for email reply
"""
config = get_braze_configuration(site_code)
try:
Expand All @@ -80,7 +83,8 @@ def send_offer_update_email_via_braze(self, user_email, subject, email_body, sen
email_ids=user_emails,
subject=subject,
body=email_body,
sender_alias=sender_alias
sender_alias=sender_alias,
reply_to=reply_to
)
except (BrazeRateLimitError, BrazeInternalServerError):
raise self.retry(countdown=config.get('BRAZE_RETRY_SECONDS'),
Expand All @@ -92,7 +96,7 @@ def send_offer_update_email_via_braze(self, user_email, subject, email_body, sen
)


def send_offer_usage_email_via_braze(self, emails, subject, email_body, site_code):
def send_offer_usage_email_via_braze(self, emails, subject, email_body, reply_to, site_code):
"""
Sends the offer usage email via braze.
Expand All @@ -101,6 +105,7 @@ def send_offer_usage_email_via_braze(self, emails, subject, email_body, site_cod
emails (str): comma separated emails.
subject (str): Email subject.
email_body (str): The body of the email.
reply_to (str): Enterprise Customer reply to address for email reply
site_code (str): Identifier of the site sending the email.
"""
config = get_braze_configuration(site_code)
Expand All @@ -110,7 +115,8 @@ def send_offer_usage_email_via_braze(self, emails, subject, email_body, site_cod
braze_client.send_message(
email_ids=user_emails,
subject=subject,
body=email_body
body=email_body,
reply_to=reply_to
)
except (BrazeRateLimitError, BrazeInternalServerError):
raise self.retry(countdown=config.get('BRAZE_RETRY_SECONDS'),
Expand Down
5 changes: 4 additions & 1 deletion ecommerce_worker/email/v1/braze/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SendEmailsViaBrazeTests(TestCase):
EMAIL_BODY = 'Template message with [email protected] GIL7RUEOU7VHBH7Q ' \
'https://tempurl.url/enroll 3 2012-04-23'
SENDER_ALIAS = 'edx Support Team'
REPLY_TO = 'no-[email protected]'
REPLY_TO = '[email protected]'
SITE_CODE = 'test'
BRAZE_CONFIG = {
'BRAZE_ENABLE': True,
Expand All @@ -61,6 +61,7 @@ class SendEmailsViaBrazeTests(TestCase):
'subject': SUBJECT,
'email_body': EMAIL_BODY,
'sender_alias': SENDER_ALIAS,
'reply_to': REPLY_TO,
'site_code': SITE_CODE,
}

Expand All @@ -69,13 +70,15 @@ class SendEmailsViaBrazeTests(TestCase):
'subject': SUBJECT,
'email_body': EMAIL_BODY,
'sender_alias': SENDER_ALIAS,
'reply_to': REPLY_TO,
'site_code': SITE_CODE,
}

USAGE_TASK_KWARGS = {
'emails': EMAILS,
'subject': SUBJECT,
'email_body': EMAIL_BODY,
'reply_to': REPLY_TO,
'site_code': SITE_CODE,
}

Expand Down
15 changes: 9 additions & 6 deletions ecommerce_worker/email/v1/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@shared_task(bind=True, ignore_result=True)
def send_offer_assignment_email(self, user_email, offer_assignment_id, subject, email_body, sender_alias,
site_code=None, base_enterprise_url='') -> None:
reply_to='', site_code=None, base_enterprise_url='') -> None:
"""
Sends the offer assignment email.
Expand All @@ -33,14 +33,15 @@ def send_offer_assignment_email(self, user_email, offer_assignment_id, subject,
site_code (str): Identifier of the site sending the email.
base_enterprise_url (str): Url for the enterprise learner portal.
sender_alias (str): Enterprise Customer sender alias used as From Name.
reply_to (str): Enterprise Customer reply to address for email reply
"""
if is_braze_enabled(site_code):
send_offer_assignment_email_via_braze(
self, user_email, offer_assignment_id, subject, email_body, sender_alias, site_code)
self, user_email, offer_assignment_id, subject, email_body, sender_alias, reply_to, site_code)


@shared_task(bind=True, ignore_result=True)
def send_offer_update_email(self, user_email, subject, email_body, sender_alias, site_code=None,
def send_offer_update_email(self, user_email, subject, email_body, sender_alias, reply_to='', site_code=None,
base_enterprise_url='') -> None:
"""
Sends the offer emails after assignment, either for revoking or reminding.
Expand All @@ -52,14 +53,15 @@ def send_offer_update_email(self, user_email, subject, email_body, sender_alias,
email_body (str): The body of the email.
site_code (str): Identifier of the site sending the email.
sender_alias (str): Enterprise Customer sender alias used as From Name.
reply_to (str): Enterprise Customer reply to address for email reply
base_enterprise_url (str): Enterprise learner portal url.
"""
if is_braze_enabled(site_code):
send_offer_update_email_via_braze(self, user_email, subject, email_body, sender_alias, site_code)
send_offer_update_email_via_braze(self, user_email, subject, email_body, sender_alias, reply_to, site_code)


@shared_task(bind=True, ignore_result=True)
def send_offer_usage_email(self, emails, subject, email_body, site_code=None,
def send_offer_usage_email(self, emails, subject, email_body, reply_to='', site_code=None,
base_enterprise_url='') -> None:
"""
Sends the offer usage email.
Expand All @@ -69,11 +71,12 @@ def send_offer_usage_email(self, emails, subject, email_body, site_code=None,
emails (str): comma separated emails.
subject (str): Email subject.
email_body (str): The body of the email.
reply_to (str): Enterprise Customer reply to address for email reply
site_code (str): Identifier of the site sending the email.
base_enterprise_url (str): Url of the enterprise's learner portal
"""
if is_braze_enabled(site_code):
send_offer_usage_email_via_braze(self, emails, subject, email_body, site_code)
send_offer_usage_email_via_braze(self, emails, subject, email_body, reply_to, site_code)


@shared_task(bind=True, ignore_result=True)
Expand Down

0 comments on commit ec1e2ff

Please sign in to comment.