[weboob] [PATCH 1/2] monboob: add the full thread history in headers

Simon Lipp laiquo at hwold.net
Fri Feb 12 09:59:25 CET 2016


Adding the full thread history (not only the direct parent, but all
message ancestors) in the References: header allow certain MUA (like
thunderbird) to continue grouping messages by thread event when the
ancestors have been deleted in the mailbox.

Signed-off-by: Simon Lipp <laiquo at hwold.net>
---
 weboob/applications/monboob/monboob.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/weboob/applications/monboob/monboob.py b/weboob/applications/monboob/monboob.py
index b942a54..a3065b2 100644
--- a/weboob/applications/monboob/monboob.py
+++ b/weboob/applications/monboob/monboob.py
@@ -278,9 +278,11 @@ class Monboob(ReplApplication):
         domain = self.config.get('domain')
         recipient = self.config.get('recipient')
 
-        reply_id = ''
-        if mail.parent:
-            reply_id = u'<%s.%s@%s>' % (backend_name, mail.parent.full_id, domain)
+        parent_message = mail.parent
+        references = []
+        while parent_message:
+            references.append(u'<%s.%s@%s>' % (backend_name, mail.parent.full_id, domain))
+            parent_message = parent_message.parent
         subject = mail.title
         sender = u'"%s" <%s@%s>' % (mail.sender.replace('"', '""') if mail.sender else '',
                                     backend_name, domain)
@@ -345,8 +347,9 @@ class Monboob(ReplApplication):
         msg['Subject'] = Header(unicode(subject), header_charset)
         msg['Message-Id'] = msg_id
         msg['Date'] = date
-        if reply_id:
-            msg['In-Reply-To'] = reply_id
+        if references:
+            msg['In-Reply-To'] = references[0]
+            msg['References'] = u" ".join(reversed(references))
 
         self.logger.info('Send mail from <%s> to <%s>' % (sender, recipient))
         if len(self.config.get('pipe')) > 0:
-- 
2.7.0



More information about the weboob mailing list