fix for checking notification types when e-mail notifications are evaluated

This commit is contained in:
Daniel Schick 2025-03-04 17:55:18 +01:00
parent 189626d61c
commit a1b807824e

View File

@ -118,7 +118,7 @@ def SendEmails(email_dict):
msg = EmailMessage()
msg["Subject"] = '[Bremen calling] Notification'
msg["From"] = defs.email_credentials["sender"]
msg["To"] = user.user_email
msg["To"] = user["user_email"]
with open(os.path.join(current_path,'../msg/notification_template.html'), mode="r", encoding="utf-8") as file:
body = file.read()
@ -170,7 +170,7 @@ def SendEmails(email_dict):
body = body.replace("[[NOTIFICATION_ELEMENTS]]", replacement)
msg.set_content(body, subtype='html', charset='utf-8', cte='8bit')
conn.sendmail(defs.email_credentials["sender"], user.user_email, msg.as_string())
conn.sendmail(defs.email_credentials["sender"], user["user_email"], msg.as_string())
except Exception as ex:
logging.error(ex)
@ -197,10 +197,10 @@ def SendNotifications():
email_dict = dict()
users_dict = dict()
user_query = "SELECT * from user"
users = commands.query(user_query, model=model.User)
users = commands.query(user_query)
for participant in participants:
for user in users:
if user.participant_id == participant.id:
if user["participant_id"] == participant.id:
if not participant.id in users_dict:
users_dict[participant.id] = []
users_dict[participant.id].append(user)
@ -215,28 +215,29 @@ def SendNotifications():
users = users_dict[assigned_participant.participant_id]
for user in users:
# send notification to user
if user.notify_email:
if user["notify_email"]:
if user not in email_dict:
email_dict[user] = []
email_dict[user].append(notification)
if user.notify_whatsapp:
if user["notify_whatsapp"]:
# TBD
pass
if user.notify_signal:
if user["notify_signal"]:
# TBD
pass
else:
users = users_dict[notification.participant_id]
for user in users:
user_notifications = model.bitflag_to_list(user["notify_event"])
# send notification to user
if user.notify_email and user.wants_notifications(notification.type):
if user["notify_email"] and notification.type in user_notifications:
if user not in email_dict:
email_dict[user] = []
email_dict[user].append(notification)
if user.notify_whatsapp and user.wants_notifications(notification.type):
if user["notify_whatsapp"] and notification.type in user_notifications:
# TBD
pass
if user.notify_signal and user.wants_notifications(notification.type):
if user["notify_signal"] and notification.type in user_notifications:
# TBD
pass