From c03119715412d1f9869fcafaa0f77e020836feb7 Mon Sep 17 00:00:00 2001 From: Amir Tadrisi Date: Tue, 2 Nov 2021 13:29:46 -0500 Subject: [PATCH 1/3] feat: Add Mandrill Subaccount support --- .../appsembler/settings/settings/aws_common.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py b/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py index d07694908f6d..6ee07c1cdfe4 100644 --- a/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py +++ b/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py @@ -40,7 +40,18 @@ def plugin_settings(settings): "MANDRILL_API_KEY": settings.MANDRILL_API_KEY, } settings.INSTALLED_APPS += ("anymail",) - + # Mandrill Subaccount Support + settings.MANDRILL_SUBACCOUNT = settings.AUTH_TOKENS.get("MANDRILL_SUBACCOUNT") + if settings.MANDRILL_SUBACCOUNT: + settings.ANYMAIL = { + "MANDRILL_SEND_DEFAULTS": { + "esp_extra": { + "message": { + "subaccount": settings.MANDRILL_SUBACCOUNT + } + } + } + } # Sentry settings.SENTRY_DSN = settings.AUTH_TOKENS.get('SENTRY_DSN', False) if settings.SENTRY_DSN: From f0827359814d0d490ae6e7ae5a053f193552b967 Mon Sep 17 00:00:00 2001 From: Amir Tadrisi Date: Tue, 2 Nov 2021 16:18:58 -0500 Subject: [PATCH 2/3] Update settings.ANYMAIL if it already exists --- .../djangoapps/appsembler/settings/settings/aws_common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py b/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py index 6ee07c1cdfe4..778de06c6559 100644 --- a/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py +++ b/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py @@ -43,7 +43,7 @@ def plugin_settings(settings): # Mandrill Subaccount Support settings.MANDRILL_SUBACCOUNT = settings.AUTH_TOKENS.get("MANDRILL_SUBACCOUNT") if settings.MANDRILL_SUBACCOUNT: - settings.ANYMAIL = { + subaccount_settings = { "MANDRILL_SEND_DEFAULTS": { "esp_extra": { "message": { @@ -52,6 +52,10 @@ def plugin_settings(settings): } } } + if settings.ANYMAIL: + settings.ANYMAIL.update(subaccount_settings) + else: + settings.ANYMAIL = subaccount_settings # Sentry settings.SENTRY_DSN = settings.AUTH_TOKENS.get('SENTRY_DSN', False) if settings.SENTRY_DSN: From 8a2be193bf49223ccdeeb297493fc77f18db44c4 Mon Sep 17 00:00:00 2001 From: Amir Tadrisi Date: Wed, 3 Nov 2021 14:25:43 -0500 Subject: [PATCH 3/3] Read MANDRILL_SUBACCOUNT ID from ENV_TOKENS --- .../core/djangoapps/appsembler/settings/settings/aws_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py b/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py index 778de06c6559..53d33eed497b 100644 --- a/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py +++ b/openedx/core/djangoapps/appsembler/settings/settings/aws_common.py @@ -41,7 +41,7 @@ def plugin_settings(settings): } settings.INSTALLED_APPS += ("anymail",) # Mandrill Subaccount Support - settings.MANDRILL_SUBACCOUNT = settings.AUTH_TOKENS.get("MANDRILL_SUBACCOUNT") + settings.MANDRILL_SUBACCOUNT = settings.ENV_TOKENS.get("MANDRILL_SUBACCOUNT") if settings.MANDRILL_SUBACCOUNT: subaccount_settings = { "MANDRILL_SEND_DEFAULTS": {