[projects/pld-builder.new] Send report mails separately to requester and list

baggins baggins at pld-linux.org
Sat Sep 27 13:59:44 CEST 2014


commit b2bdcf0e31ca6676086e8a5fd72d9a80cec2725e
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sat Sep 27 13:50:21 2014 +0200

    Send report mails separately to requester and list
    
    "Some" mail providers do deduplication solely based on the
    message-id, thus making mail sent to list and requester show
    only once if requester is subscribed to list.
    By sending two mails with different message-id we can work
    around this.

 PLD_Builder/mailer.py |  4 ++++
 PLD_Builder/report.py | 28 ++++++++++++++++++++--------
 2 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/PLD_Builder/mailer.py b/PLD_Builder/mailer.py
index e0b3ae6..c7d8733 100644
--- a/PLD_Builder/mailer.py
+++ b/PLD_Builder/mailer.py
@@ -32,6 +32,10 @@ class Message:
         if subject != None:
             self.set_header("Subject", subject)
 
+    def remove_header(self, n):
+        if n in self.headers:
+          del self.headers[n]
+
     def write_line(self, l):
         self.body.write(recode("%s\n" % l))
 
diff --git a/PLD_Builder/report.py b/PLD_Builder/report.py
index f2b3436..865fa4a 100644
--- a/PLD_Builder/report.py
+++ b/PLD_Builder/report.py
@@ -72,15 +72,8 @@ def send_report(r, is_src = False):
     subject += ' '.join((s_failed, s_ok)).strip()
 
     m = mailer.Message()
-    m.set_headers(to = r.requester_email,
-                  cc = config.builder_list,
-                  subject = subject[0:100])
-    if is_src:
-        m.set_header("Message-ID", "<%s at pld.src.builder>" % r.id)
-    else:
-        m.set_header("References", "<%s at pld.src.builder>" % r.id)
-        m.set_header("In-Reply-To", "<%s at pld.src.builder>" % r.id)
 
+    m.write("Request by: %s\n\n" % r.requester_email)
     for b in r.batches:
         if b.build_failed and b.logfile == None:
             info = b.skip_reason
@@ -100,6 +93,25 @@ def send_report(r, is_src = False):
             m.append_log(b.logfile)
             m.write("\n\n")
 
+    m.set_headers(to = r.requester_email,
+                  subject = subject[0:100])
+    if is_src:
+        m.set_header("Message-ID", "<req-%s at pld.src.builder>" % r.id)
+    else:
+        m.set_header("References", "<req-%s at pld.src.builder>" % r.id)
+        m.set_header("In-Reply-To", "<req-%s at pld.src.builder>" % r.id)
+    m.send()
+
+    m.remove_header("To")
+    m.remove_header("Cc")
+    m.set_header("To", config.builder_list)
+    # reset Message-ID
+    m.set_std_headers()
+    if is_src:
+        m.set_header("Message-ID", "<%s at pld.src.builder>" % r.id)
+    else:
+        m.set_header("References", "<%s at pld.src.builder>" % r.id)
+        m.set_header("In-Reply-To", "<%s at pld.src.builder>" % r.id)
     m.send()
 
 def send_cia_report(r, is_src = False):
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/b2bdcf0e31ca6676086e8a5fd72d9a80cec2725e



More information about the pld-cvs-commit mailing list