diff roundup/mailgw.py @ 694:34dbcdfb2fe1

stripping of email message body can be controlled through config variables... ...EMAIL_KEEP_QUOTED_TEST and EMAIL_LEAVE_BODY_UNCHANGED.
author Roche Compaan <rochecompaan@users.sourceforge.net>
date Tue, 23 Apr 2002 15:46:49 +0000
parents cdcee6721841
children 676d4cfde9a5
line wrap: on
line diff
--- a/roundup/mailgw.py	Mon Apr 15 23:25:15 2002 +0000
+++ b/roundup/mailgw.py	Tue Apr 23 15:46:49 2002 +0000
@@ -73,7 +73,7 @@
 an exception, the original message is bounced back to the sender with the
 explanatory message given in the exception. 
 
-$Id: mailgw.py,v 1.66 2002-03-14 23:59:24 richard Exp $
+$Id: mailgw.py,v 1.67 2002-04-23 15:46:49 rochecompaan Exp $
 '''
 
 
@@ -597,7 +597,10 @@
         else:
             content = self.get_part_data_decoded(message) 
  
-        summary, content = parseContent(content)
+        keep_citations = self.instance.EMAIL_KEEP_QUOTED_TEXT == 'yes'
+        keep_body = self.instance.EMAIL_LEAVE_BODY_UNCHANGED == 'yes'
+        summary, content = parseContent(content, keep_citations, 
+            keep_body)
 
         # 
         # handle the attachments
@@ -745,8 +748,10 @@
             # commit the new node(s) to the DB
             self.db.commit()
 
-def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
-        eol=re.compile(r'[\r\n]+'), signature=re.compile(r'^[>|\s]*[-_]+\s*$')):
+def parseContent(content, keep_citations, keep_body,
+        blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
+        eol=re.compile(r'[\r\n]+'), 
+        signature=re.compile(r'^[>|\s]*[-_]+\s*$')):
     ''' The message body is divided into sections by blank lines.
     Sections where the second and all subsequent lines begin with a ">" or "|"
     character are considered "quoting sections". The first line of the first
@@ -778,9 +783,9 @@
                 if line[0] not in '>|':
                     break
             else:
-                # TODO: people who want to keep quoted bits will want the
-                # next line...
-                # l.append(section)
+                # we keep quoted bits if specified in the config
+                if keep_citations:
+                    l.append(section)
                 continue
             # keep this section - it has reponse stuff in it
             if not summary:
@@ -799,10 +804,17 @@
 
         # and add the section to the output
         l.append(section)
-    return summary, '\n\n'.join(l)
+    # we only set content for those who want to delete cruft from the
+    # message body, otherwise the body is left untouched.
+    if not keep_body:
+        content = '\n\n'.join(l)
+    return summary, content
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.66  2002/03/14 23:59:24  richard
+#  . #517734 ] web header customisation is obscure
+#
 # Revision 1.65  2002/02/15 00:13:38  richard
 #  . #503204 ] mailgw needs a default class
 #     - partially done - the setting of additional properties can wait for a

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