diff roundup/mailgw.py @ 5117:14abd0a67207

Fix issue934009: Have New Issues Submitted By Email *Not* Change Body! The mailgw config options: keep_quoted_text and leave_body_unchanged can now have a new values: new. If set to new, keep_quoted_text acts like yes if the message is starting a new issue. Otherise it strips quoted text. This allows somebody to start a new issue by forwarding a threaded email (with multiple quoted parts) into roundup and keeping all the quoted parts. If leave_body_unchanged is set to new, even the signature on the email that starts a new issue will be preserved.
author John Rouillard <rouilj@ieee.org>
date Sat, 02 Jul 2016 20:05:06 -0400
parents d3d9d1402763
children 6bbb6dd97458
line wrap: on
line diff
--- a/roundup/mailgw.py	Sat Jul 02 17:55:23 2016 -0400
+++ b/roundup/mailgw.py	Sat Jul 02 20:05:06 2016 -0400
@@ -1138,9 +1138,8 @@
 Roundup requires the submission to be plain text. The message parser could
 not find a text/plain part to use.
 """)
-
         # parse the body of the message, stripping out bits as appropriate
-        summary, content = parseContent(self.content, config=self.config)
+        summary, content = parseContent(self.content, config=self.config, is_new_issue = not bool(self.nodeid))
         content = content.strip()
 
         if content:
@@ -1782,7 +1781,7 @@
     else:
         return 0
 
-def parseContent(content, keep_citations=None, keep_body=None, config=None):
+def parseContent(content, keep_citations=None, keep_body=None, config=None, is_new_issue=False):
     """Parse mail message; return message summary and stripped content
 
     The message body is divided into sections by blank lines.
@@ -1806,8 +1805,30 @@
         config = configuration.CoreConfig()
     if keep_citations is None:
         keep_citations = config["MAILGW_KEEP_QUOTED_TEXT"]
+        if keep_citations == "new":
+            # don't strip citations if we are a new issue
+            if is_new_issue:
+                keep_citations = True
+            else:
+                keep_citations = False
+        elif keep_citations == "yes":
+            keep_citations = True
+        else:
+            keep_citations = False
+
     if keep_body is None:
         keep_body = config["MAILGW_LEAVE_BODY_UNCHANGED"]
+        if keep_body == "new":
+            # don't strip citations if we are a new issue
+            if is_new_issue:
+                keep_body = True
+            else:
+                keep_body = False
+        elif keep_body == "yes":
+            keep_body = True
+        else:
+            keep_body = False
+
     eol = config["MAILGW_EOL_RE"]
     signature = config["MAILGW_SIGN_RE"]
     original_msg = config["MAILGW_ORIGMSG_RE"]

Roundup Issue Tracker: http://roundup-tracker.org/