From 29b611c780be5375653e0ca771712bc27f01ed2a Mon Sep 17 00:00:00 2001 From: Max Metz Date: Wed, 31 Jul 2024 15:30:06 +0200 Subject: [PATCH] instead of overwriting the recipient's addresses, the bsmd address will simply (always) be added to the list of recipients. --- src/server/BreCal/notifications/notifier.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/server/BreCal/notifications/notifier.py b/src/server/BreCal/notifications/notifier.py index 30db745..4e38d7e 100644 --- a/src/server/BreCal/notifications/notifier.py +++ b/src/server/BreCal/notifications/notifier.py @@ -407,6 +407,18 @@ class Notifier(): schemas = execute_sql_query_standalone(query=query, param=schemaModel, command_type="execute") return + @staticmethod + def build_email_targets_validation_notification(users)->list[str]: + # readout the email address of all users + email_tgts = [user.user_email for user in users if user.user_email is not None] + + # additionally, always inform the BSMD + email_tgts.append("bremencalling@bsmd.de") # #TODO: for testing, use "bremencalling@bsmd.de". For live system, use "report@bsmd.de" + + # avoid multi-mails, when (for some reason) multiple users share the same email address. + email_tgts = list(set(email_tgts)) + return email_tgts + @staticmethod def create_and_send_email_notification(email_handler:EmailHandler, pwd:bytes, users:list[model.User], notification:model.Notification, update_database:bool=True, debug:bool=False): """ @@ -415,11 +427,8 @@ class Notifier(): this 'naive' method creates a message and simply sends it to all users in a list of users. Afterwards, the database will be updated, so the shipcall no longer requires a notification. """ - #email_tgts = [user.user_email for user in users if user.user_email is not None] - email_tgts = ["bremencalling@bsmd.de" for user in users if user.user_email is not None] - - # avoid multi-mails, when (for some reason) multiple users share the same email address. - email_tgts = list(set(email_tgts)) + # get a list of all recipients + email_tgts = Notifier.build_email_targets_validation_notification(users) # prepare and build the Email content content = get_default_html_email()