From b7f4dc65a7f73efd015f47436d86a965755b3091 Mon Sep 17 00:00:00 2001 From: Andy Byers Date: Fri, 23 Feb 2024 15:53:29 +0000 Subject: [PATCH] #3992 ensures that the bounce email system only first for configured targets (currently Article and Preprint objects). --- src/utils/logic.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/utils/logic.py b/src/utils/logic.py index 825311f8d5..136144f092 100644 --- a/src/utils/logic.py +++ b/src/utils/logic.py @@ -95,25 +95,28 @@ def send_bounce_notification_to_event_actor(event): request.site_type = target.repository request.repository = target.repository - # Setup log dict - log_dict = { - 'level': 'Info', - 'action_text': 'Email Delivery Failed ', - 'types': 'Email Delivery', - 'target': target, - } - - notify_helpers.send_email_with_body_from_setting_template( - request=request, - template='bounced_email_notification', - subject='subject_bounced_email_notification', - to=to, - context={ + # currently this feature is set up for article and preprint emails. + # if no site type is set, we shouldn't try to send a bounce email. + if request.site_type: + # Setup log dict + log_dict = { + 'level': 'Info', + 'action_text': 'Email Delivery Failed ', + 'types': 'Email Delivery', 'target': target, - 'event': event, - }, - log_dict=log_dict, - ) + } + + notify_helpers.send_email_with_body_from_setting_template( + request=request, + template='bounced_email_notification', + subject='subject_bounced_email_notification', + to=to, + context={ + 'target': target, + 'event': event, + }, + log_dict=log_dict, + ) def build_url_for_request(request=None, path="", query=None, fragment=""):