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

Commit

Permalink
fix: ignore Braze frequency capping for ent emails
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Jan 6, 2022
1 parent 20d706b commit 8facf88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion ecommerce_worker/email/v1/braze/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ def send_message( # pylint: disable=dangerous-default-value
):
"""
Sends the message via Braze Rest API /messages/send
The "override_frequency_capping" key in the request payload is important;
it tells Braze to ignore the global campaign message frequency cap
for the message we're sending in this method. Since this is a transactional
message, we'd like the recipient to receive it regardless of what/how-many
other campaign messages they have received.
Arguments:
email_ids (list): e.g. ['[email protected]', '[email protected]']
Expand All @@ -318,6 +323,7 @@ def send_message( # pylint: disable=dangerous-default-value
{
"external_user_ids": [ "[email protected]", "[email protected]" ],
"campaign_id": "some-campaign-identifier",
"override_frequency_capping": true,
"messages": {
"email": {
"app_id": "99999999-9999-9999-9999-999999999999",
Expand Down Expand Up @@ -374,12 +380,15 @@ def send_message( # pylint: disable=dangerous-default-value
message = {
'user_aliases': user_aliases,
'external_user_ids': external_ids,
'campaign_id': campaign_id,
'recipient_subscription_state': 'all',
'messages': {
'email': email
}
}
if campaign_id:
message['campaign_id'] = campaign_id
message['override_frequency_capping'] = True

# Scrub the app_id from the log message
cleaned_message = copy.deepcopy(message)
cleaned_app_id = '{}...{}'.format(cleaned_message['messages']['email']['app_id'][0:4],
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def is_requirement(line):

setup(
name='edx-ecommerce-worker',
version='3.1.1',
version='3.1.2',
description='Celery tasks supporting the operations of edX\'s ecommerce service',
long_description=long_description,
classifiers=[
Expand Down

0 comments on commit 8facf88

Please sign in to comment.