From 9cb47086429eb430d6a025ec39f01cdf7636dc3d Mon Sep 17 00:00:00 2001 From: Matthew Elwell Date: Wed, 21 Aug 2024 10:35:34 +0100 Subject: [PATCH] Refactor to send to still customersuccess@flagsmith.com --- api/app/settings/common.py | 4 ++++ api/organisations/tasks.py | 14 ++++++++++---- .../ecs-task-definition-task-processor.json | 4 ++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/api/app/settings/common.py b/api/app/settings/common.py index c3fdc55384c7..1caf32b07be7 100644 --- a/api/app/settings/common.py +++ b/api/app/settings/common.py @@ -1238,3 +1238,7 @@ "EDGE_V2_MIGRATION_READ_CAPACITY_BUDGET", default=0, ) + +ORG_SUBSCRIPTION_CANCELLED_ALERT_RECIPIENT_LIST = env.list( + "ORG_SUBSCRIPTION_CANCELLED_ALERT_RECIPIENT_LIST", default=[] +) diff --git a/api/organisations/tasks.py b/api/organisations/tasks.py index 0b3b9267f7c2..11add1bc7990 100644 --- a/api/organisations/tasks.py +++ b/api/organisations/tasks.py @@ -4,6 +4,7 @@ from app_analytics.influxdb_wrapper import get_current_api_usage from django.conf import settings +from django.core.mail import send_mail from django.db.models import F, Max, Q from django.utils import timezone from task_processor.decorators import ( @@ -73,10 +74,15 @@ def send_org_subscription_cancelled_alert( organisation_name: str, formatted_cancellation_date: str, ) -> None: - FFAdminUser.send_alert_to_admin_users( - subject=f"Organisation {organisation_name} has cancelled their subscription", - message=f"Organisation {organisation_name} has cancelled their subscription on {formatted_cancellation_date}", - ) + if recipient_list := settings.ORG_SUBSCRIPTION_CANCELLED_ALERT_RECIPIENT_LIST: + send_mail( + subject=f"Organisation {organisation_name} has cancelled their subscription", + message=f"Organisation {organisation_name} has cancelled their subscription " + f"on {formatted_cancellation_date}", + from_email=settings.DEFAULT_FROM_EMAIL, + recipient_list=[recipient_list], + fail_silently=True, + ) @register_recurring_task( diff --git a/infrastructure/aws/production/ecs-task-definition-task-processor.json b/infrastructure/aws/production/ecs-task-definition-task-processor.json index 781de824f235..ffa8f1fbc954 100644 --- a/infrastructure/aws/production/ecs-task-definition-task-processor.json +++ b/infrastructure/aws/production/ecs-task-definition-task-processor.json @@ -168,6 +168,10 @@ { "name": "ENABLE_API_USAGE_ALERTING", "value": "True" + }, + { + "name": "ORG_SUBSCRIPTION_CANCELLED_ALERT_RECIPIENT_LIST", + "value": "customersuccess@flagsmith.com" } ], "secrets": [