From d651d54dba7b3ed19637d2d0273c5e35ce3f5c12 Mon Sep 17 00:00:00 2001 From: Hamzah Ullah Date: Mon, 6 May 2024 15:00:43 +0000 Subject: [PATCH] chore: upgrade version to 4.18.0 --- enterprise/tasks.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/enterprise/tasks.py b/enterprise/tasks.py index 1134537f93..54375a1481 100644 --- a/enterprise/tasks.py +++ b/enterprise/tasks.py @@ -213,6 +213,18 @@ def send_sso_configured_email( raise exc +def _recipients_for_identified_users(user_id_by_email): + braze_client_instance = BrazeAPIClient() + recipients = [] + for user_id_by_email_chunk in batch_dict(user_id_by_email, MAX_NUM_IDENTIFY_USERS_ALIASES): + recipients_by_email = braze_client_instance.create_recipients( + alias_label=ENTERPRISE_BRAZE_ALIAS_LABEL, + user_id_by_email=user_id_by_email_chunk + ) + recipients.extend(recipients_by_email.values()) + return recipients + + @shared_task @set_code_owner_attribute def send_group_membership_invitation_notification( @@ -260,13 +272,7 @@ def send_group_membership_invitation_notification( [pecu_emails], ENTERPRISE_BRAZE_ALIAS_LABEL, ) - for user_id_by_email_chunk in batch_dict(user_id_by_email, MAX_NUM_IDENTIFY_USERS_ALIASES): - recipients_by_email = braze_client_instance.create_recipients( - alias_label=ENTERPRISE_BRAZE_ALIAS_LABEL, - user_id_by_email=user_id_by_email_chunk - ) - for _, recipient in recipients_by_email.items(): - recipients.append(recipient) + recipients.extend(_recipients_for_identified_users(user_id_by_email)) try: braze_client_instance.send_campaign_message( settings.BRAZE_GROUPS_INVITATION_EMAIL_CAMPAIGN_ID, @@ -321,13 +327,7 @@ def send_group_membership_removal_notification(enterprise_customer_uuid, members [pecu_emails], ENTERPRISE_BRAZE_ALIAS_LABEL, ) - for user_id_by_email_chunk in batch_dict(user_id_by_email, MAX_NUM_IDENTIFY_USERS_ALIASES): - recipients_by_email = braze_client_instance.create_recipients( - alias_label=ENTERPRISE_BRAZE_ALIAS_LABEL, - user_id_by_email=user_id_by_email_chunk - ) - for _, recipient in recipients_by_email.items(): - recipients.append(recipient) + recipients.extend(_recipients_for_identified_users(user_id_by_email)) try: braze_client_instance.send_campaign_message( settings.BRAZE_GROUPS_REMOVAL_EMAIL_CAMPAIGN_ID,