[pmg-devel] [PATCH pmg-log-filter] before-queue: set 'B' status for rule-system blocked mails
Dominik Csapak
d.csapak at proxmox.com
Fri Apr 24 11:26:50 CEST 2020
we want to show mails that were blocked by the rule-system as 'Blocked'
in the ui, so we have to use the dstatus of the to entry, and not
'NOQUEUE'
mails rejected by postscreen, etc. still show 'rejected'
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/main.rs | 18 ++++--------------
tests/test_output_before_queue | 2 +-
tests/test_output_before_queue_host | 2 +-
tests/test_output_before_queue_search_string | 2 +-
4 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index fa75f01..6c5291b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -976,19 +976,11 @@ impl SEntry {
let print_filter_to_entries_fn =
|fe: &Rc<RefCell<FEntry>>,
parser: &mut Parser,
- se: &SEntry,
- dstatus: Option<DStatus>| {
- let mut dstatus = match dstatus {
- Some(d) => d,
- None => DStatus::Invalid,
- };
+ se: &SEntry| {
for to in fe.borrow().to_entries.iter().rev() {
- if dstatus == DStatus::Invalid {
- dstatus = to.dstatus;
- }
parser.write_all_ok(format!(
"TO:{:X}:T{:08X}L{:08X}:{}: from <",
- to.timestamp as i32, se.timestamp as i32, se.rel_line_nr, dstatus,
+ to.timestamp as i32, se.timestamp as i32, se.rel_line_nr, to.dstatus,
));
parser.write_all_ok(&se.bq_from);
parser.write_all_ok(b"> to <");
@@ -1002,10 +994,8 @@ impl SEntry {
if let Some(fe) = &self.filter() {
// limited to !fe.is_accepted because otherwise we would have
// a QEntry with all required information instead
- if fe.borrow().is_bq && !fe.borrow().is_accepted && self.is_bq_accepted {
- print_filter_to_entries_fn(&fe, parser, self, None);
- } else if fe.borrow().is_bq && !fe.borrow().is_accepted && self.is_bq_rejected {
- print_filter_to_entries_fn(&fe, parser, self, Some(DStatus::Noqueue));
+ if fe.borrow().is_bq && !fe.borrow().is_accepted && (self.is_bq_accepted || self.is_bq_rejected) {
+ print_filter_to_entries_fn(&fe, parser, self);
}
}
diff --git a/tests/test_output_before_queue b/tests/test_output_before_queue
index b9d82af..46e90dc 100644
--- a/tests/test_output_before_queue
+++ b/tests/test_output_before_queue
@@ -7,7 +7,7 @@
SMTPD: T5FDCC4EFL00000000
CTIME: 5FDCC4EF
CLIENT: pmg.localhost[192.168.22.40]
-TO:5FDCC4EF:T5FDCC4EFL00000000:N: from <mailtestsender2 at localhost.localdomain> to <pmgtest at localhost.localdomain>
+TO:5FDCC4EF:T5FDCC4EFL00000000:B: from <mailtestsender2 at localhost.localdomain> to <pmgtest at localhost.localdomain>
LOGS:
L00000002 Dec 18 15:04:15 pmg postfix/smtpd[21842]: connect from pmg.localhost[192.168.22.40]
L00000003 Dec 18 15:04:15 pmg postfix/smtpd[21842]: NOQUEUE: client=pmg.localhost[192.168.22.40]
diff --git a/tests/test_output_before_queue_host b/tests/test_output_before_queue_host
index d595c21..31d70bf 100644
--- a/tests/test_output_before_queue_host
+++ b/tests/test_output_before_queue_host
@@ -8,7 +8,7 @@
SMTPD: T5FDCC4EFL00000000
CTIME: 5FDCC4EF
CLIENT: pmg.localhost[192.168.22.40]
-TO:5FDCC4EF:T5FDCC4EFL00000000:N: from <mailtestsender2 at localhost.localdomain> to <pmgtest at localhost.localdomain>
+TO:5FDCC4EF:T5FDCC4EFL00000000:B: from <mailtestsender2 at localhost.localdomain> to <pmgtest at localhost.localdomain>
LOGS:
L00000002 Dec 18 15:04:15 pmg postfix/smtpd[21842]: connect from pmg.localhost[192.168.22.40]
L00000003 Dec 18 15:04:15 pmg postfix/smtpd[21842]: NOQUEUE: client=pmg.localhost[192.168.22.40]
diff --git a/tests/test_output_before_queue_search_string b/tests/test_output_before_queue_search_string
index a6725e0..17d769f 100644
--- a/tests/test_output_before_queue_search_string
+++ b/tests/test_output_before_queue_search_string
@@ -8,7 +8,7 @@
SMTPD: T5FDCC4EFL00000000
CTIME: 5FDCC4EF
CLIENT: pmg.localhost[192.168.22.40]
-TO:5FDCC4EF:T5FDCC4EFL00000000:N: from <mailtestsender2 at localhost.localdomain> to <pmgtest at localhost.localdomain>
+TO:5FDCC4EF:T5FDCC4EFL00000000:B: from <mailtestsender2 at localhost.localdomain> to <pmgtest at localhost.localdomain>
LOGS:
L00000002 Dec 18 15:04:15 pmg postfix/smtpd[21842]: connect from pmg.localhost[192.168.22.40]
L00000003 Dec 18 15:04:15 pmg postfix/smtpd[21842]: NOQUEUE: client=pmg.localhost[192.168.22.40]
--
2.20.1
More information about the pmg-devel
mailing list