[pmg-devel] [PATCH pmg-log-tracker 2/3] print blocked/quarantined entries if accepted mail exists

Mira Limbeck m.limbeck at proxmox.com
Fri May 15 16:49:05 CEST 2020


In the case of before-queue filtering we have the separation 'QEntry'
for accepted mails, as those are the only ones with a queue. And
'SEntry' for blocked and quarantined mails. But if a mail is accepted
for one address, but at the same time blocked or quarantined for another
address we previously discarded those entries. To fix it we now print it
in the 'QEntry' if the attached filter contains blocked and/or
quarantined mails.

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
 src/main.rs | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/main.rs b/src/main.rs
index 55e1516..f3c6f52 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1479,6 +1479,34 @@ impl QEntry {
             }
         }
 
+        if self.bq_filtered {
+            if let Some(fe) = &fe {
+                if fe.borrow().finished && fe.borrow().is_bq {
+                    fe.borrow_mut().to_entries.retain(|to| {
+                        for to2 in self.to_entries.iter().rev() {
+                            if to.to == to2.to {
+                                return false;
+                            }
+                        }
+                        true
+                    });
+
+                    for to in fe.borrow().to_entries.iter().rev() {
+                        parser.write_all_ok(format!("TO:{:X}:", to.timestamp as i32,));
+                        parser.write_all_ok(&self.qid);
+                        parser.write_all_ok(format!(":{}: from <", to.dstatus));
+                        parser.write_all_ok(&self.from);
+                        parser.write_all_ok(b"> to <");
+                        parser.write_all_ok(&to.to);
+                        parser.write_all_ok(b"> (");
+                        parser.write_all_ok(&to.relay);
+                        parser.write_all_ok(b")\n");
+                        parser.count += 1;
+                    }
+                }
+            }
+        }
+
         // print logs if '-vv' is specified
         if parser.options.verbose > 1 {
             let print_log = |parser: &mut Parser, logs: &Vec<(Box<[u8]>, u64)>| {
-- 
2.20.1




More information about the pmg-devel mailing list