From: rochecompaan Date: Tue, 23 Apr 2002 15:46:49 +0000 (+0000) Subject: . stripping of the email message body can now be controlled through X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4f023ab4171ffdb9e1e474d8070591f3163a247f;p=roundup.git . stripping of the email message body can now be controlled through the config variables EMAIL_KEEP_QUOTED_TEST and EMAIL_LEAVE_BODY_UNCHANGED. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@708 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 10a2368..1650c39 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -19,6 +19,8 @@ Feature:
View: + . stripping of the email message body can now be controlled through the + config variables EMAIL_KEEP_QUOTED_TEXT and EMAIL_LEAVE_BODY_UNCHANGED. Fixed: . stop sending blank (whitespace-only) notes diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 3dbf229..c496772 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -73,7 +73,7 @@ are calling the create() method to create a new node). If an auditor raises 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 @@ not find a text/plain part to use. 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 @@ There was a problem with the message you sent: # 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 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), 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 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), # 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 diff --git a/roundup/templates/classic/instance_config.py b/roundup/templates/classic/instance_config.py index d6e7622..cc57d2a 100644 --- a/roundup/templates/classic/instance_config.py +++ b/roundup/templates/classic/instance_config.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: instance_config.py,v 1.13 2002-03-14 23:59:24 richard Exp $ +# $Id: instance_config.py,v 1.14 2002-04-23 15:46:49 rochecompaan Exp $ MAIL_DOMAIN=MAILHOST=HTTP_HOST=None HTTP_PORT=0 @@ -83,6 +83,12 @@ MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no' # Where to place the email signature EMAIL_SIGNATURE_POSITION = 'bottom' +# Keep email citations +EMAIL_KEEP_QUOTED_TEXT = 'no' + +# Preserve the email body as is +EMAIL_LEAVE_BODY_UNCHANGED = 'no' + # Default class to use in the mailgw if one isn't supplied in email # subjects. To disable, comment out the variable below or leave it blank. # Examples: @@ -144,6 +150,9 @@ USER_INDEX = { # # $Log: not supported by cvs2svn $ +# Revision 1.13 2002/03/14 23:59:24 richard +# . #517734 ] web header customisation is obscure +# # Revision 1.12 2002/02/15 00:13:38 richard # . #503204 ] mailgw needs a default class # - partially done - the setting of additional properties can wait for a diff --git a/roundup/templates/extended/instance_config.py b/roundup/templates/extended/instance_config.py index b737312..e60c930 100644 --- a/roundup/templates/extended/instance_config.py +++ b/roundup/templates/extended/instance_config.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: instance_config.py,v 1.13 2002-03-14 23:59:24 richard Exp $ +# $Id: instance_config.py,v 1.14 2002-04-23 15:46:49 rochecompaan Exp $ MAIL_DOMAIN=MAILHOST=HTTP_HOST=None HTTP_PORT=0 @@ -83,6 +83,12 @@ MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no' # Where to place the email signature EMAIL_SIGNATURE_POSITION = 'bottom' +# Keep email citations +EMAIL_KEEP_QUOTED_TEXT = 'no' + +# Preserve the email body as is +EMAIL_LEAVE_BODY_UNCHANGED = 'no' + # Default class to use in the mailgw if one isn't supplied in email # subjects. To disable, comment out the variable below or leave it blank. # Examples: @@ -181,6 +187,9 @@ MY_SUPPORT_INDEX = { # # $Log: not supported by cvs2svn $ +# Revision 1.13 2002/03/14 23:59:24 richard +# . #517734 ] web header customisation is obscure +# # Revision 1.12 2002/02/15 00:13:38 richard # . #503204 ] mailgw needs a default class # - partially done - the setting of additional properties can wait for a