From 0e3a5c3d3cc0ec4c2a0da9b971f8a9d51879d3f2 Mon Sep 17 00:00:00 2001 From: Son Date: Wed, 9 Mar 2022 17:58:26 +0100 Subject: [PATCH 1/4] mark a notification as read when user arrives on the notification page --- app/dashboard/views/notification.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/dashboard/views/notification.py b/app/dashboard/views/notification.py index 82270e4f..e22c8e2c 100644 --- a/app/dashboard/views/notification.py +++ b/app/dashboard/views/notification.py @@ -23,6 +23,10 @@ def notification_route(notification_id): ) return redirect(url_for("dashboard.index")) + if not notification.read: + notification.read = True + Session.commit() + if request.method == "POST": notification_title = notification.title or notification.message[:20] Notification.delete(notification_id) From fb00c18d5ae7b42ae0101f34be8d49f7371787e4 Mon Sep 17 00:00:00 2001 From: Son Date: Wed, 9 Mar 2022 17:59:02 +0100 Subject: [PATCH 2/4] create a notification when an alias is disabled --- email_handler.py | 9 +++++++++ templates/notification/alias-disable.html | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 templates/notification/alias-disable.html diff --git a/email_handler.py b/email_handler.py index e76de0ec..53831062 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1403,6 +1403,15 @@ def handle_bounce_forward_phase(msg: Message, email_log: EmailLog): alias.enabled = False Session.commit() + Notification.create( + user_id=user.id, + title=f"{alias.email} has been disabled due to multiple bounces", + message=Notification.render( + "notification/alias-disable.html", alias=alias, mailbox=mailbox + ), + commit=True, + ) + send_email_with_rate_control( user, ALERT_BOUNCE_EMAIL, diff --git a/templates/notification/alias-disable.html b/templates/notification/alias-disable.html new file mode 100644 index 00000000..9c2b6720 --- /dev/null +++ b/templates/notification/alias-disable.html @@ -0,0 +1,10 @@ +
+ There are several emails sent to your alias {{ alias.email }} that have been bounced by your + mailbox {{ mailbox.email }}. +
+ +
+ As security measure, we have disabled the alias {{ alias.email }}. + +
+ From e0b5bd36a6099517e7c77beb7d97c82bde91fa4d Mon Sep 17 00:00:00 2001 From: Son Date: Wed, 9 Mar 2022 17:59:42 +0100 Subject: [PATCH 3/4] show "more" only when a notification has a title. Show either title or message. Use bold font when a notification isn't read --- templates/header.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/templates/header.html b/templates/header.html index 3e602142..656317ba 100644 --- a/templates/header.html +++ b/templates/header.html @@ -38,15 +38,13 @@