From fd49958a00cb8c98f2e81a95c4d0d46aa04ae450 Mon Sep 17 00:00:00 2001 From: Kristian Feldsam Date: Tue, 24 Mar 2020 15:51:03 +0100 Subject: [PATCH] Quarantine notifications - don't send if sender is blacklisted (#3428) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristián Feldsam --- data/Dockerfiles/dovecot/quarantine_notify.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/Dockerfiles/dovecot/quarantine_notify.py b/data/Dockerfiles/dovecot/quarantine_notify.py index a4a67f91..113bf8c4 100755 --- a/data/Dockerfiles/dovecot/quarantine_notify.py +++ b/data/Dockerfiles/dovecot/quarantine_notify.py @@ -97,7 +97,10 @@ def notify_rcpt(rcpt, msg_count, quarantine_acl): print('%s' % (ex)) time.sleep(3) -records = query_mysql('SELECT IFNULL(user_acl.quarantine, 0) AS quarantine_acl, count(id) AS counter, rcpt FROM quarantine LEFT OUTER JOIN user_acl ON user_acl.username = rcpt WHERE notified = 0 AND rcpt in (SELECT username FROM mailbox) GROUP BY rcpt') +records = query_mysql('SELECT IFNULL(user_acl.quarantine, 0) AS quarantine_acl, count(id) AS counter, rcpt, sender FROM quarantine LEFT OUTER JOIN user_acl ON user_acl.username = rcpt WHERE notified = 0 AND rcpt in (SELECT username FROM mailbox) +# dont send notifications for blacklisted senders +AND (SELECT prefid FROM filterconf WHERE option = "blacklist_from" AND (object = rcpt OR object = SUBSTRING(rcpt, LOCATE("@", rcpt) + 1)) AND sender REGEXP(REPLACE(value, '*', '.+'))) IS NULL +GROUP BY rcpt') for record in records: attrs = ''