comparison 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
comparison
equal deleted inserted replaced
690:509a101305da 694:34dbcdfb2fe1
71 set() method to add the message to the item's spool; in the second case we 71 set() method to add the message to the item's spool; in the second case we
72 are calling the create() method to create a new node). If an auditor raises 72 are calling the create() method to create a new node). If an auditor raises
73 an exception, the original message is bounced back to the sender with the 73 an exception, the original message is bounced back to the sender with the
74 explanatory message given in the exception. 74 explanatory message given in the exception.
75 75
76 $Id: mailgw.py,v 1.66 2002-03-14 23:59:24 richard Exp $ 76 $Id: mailgw.py,v 1.67 2002-04-23 15:46:49 rochecompaan Exp $
77 ''' 77 '''
78 78
79 79
80 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri 80 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
81 import time, random 81 import time, random
595 ''' 595 '''
596 596
597 else: 597 else:
598 content = self.get_part_data_decoded(message) 598 content = self.get_part_data_decoded(message)
599 599
600 summary, content = parseContent(content) 600 keep_citations = self.instance.EMAIL_KEEP_QUOTED_TEXT == 'yes'
601 keep_body = self.instance.EMAIL_LEAVE_BODY_UNCHANGED == 'yes'
602 summary, content = parseContent(content, keep_citations,
603 keep_body)
601 604
602 # 605 #
603 # handle the attachments 606 # handle the attachments
604 # 607 #
605 files = [] 608 files = []
743 '''%message 746 '''%message
744 747
745 # commit the new node(s) to the DB 748 # commit the new node(s) to the DB
746 self.db.commit() 749 self.db.commit()
747 750
748 def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), 751 def parseContent(content, keep_citations, keep_body,
749 eol=re.compile(r'[\r\n]+'), signature=re.compile(r'^[>|\s]*[-_]+\s*$')): 752 blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
753 eol=re.compile(r'[\r\n]+'),
754 signature=re.compile(r'^[>|\s]*[-_]+\s*$')):
750 ''' The message body is divided into sections by blank lines. 755 ''' The message body is divided into sections by blank lines.
751 Sections where the second and all subsequent lines begin with a ">" or "|" 756 Sections where the second and all subsequent lines begin with a ">" or "|"
752 character are considered "quoting sections". The first line of the first 757 character are considered "quoting sections". The first line of the first
753 non-quoting section becomes the summary of the message. 758 non-quoting section becomes the summary of the message.
754 ''' 759 '''
776 # no blank line between quoted message and response) 781 # no blank line between quoted message and response)
777 for line in lines[1:]: 782 for line in lines[1:]:
778 if line[0] not in '>|': 783 if line[0] not in '>|':
779 break 784 break
780 else: 785 else:
781 # TODO: people who want to keep quoted bits will want the 786 # we keep quoted bits if specified in the config
782 # next line... 787 if keep_citations:
783 # l.append(section) 788 l.append(section)
784 continue 789 continue
785 # keep this section - it has reponse stuff in it 790 # keep this section - it has reponse stuff in it
786 if not summary: 791 if not summary:
787 # and while we're at it, use the first non-quoted bit as 792 # and while we're at it, use the first non-quoted bit as
788 # our summary 793 # our summary
797 elif signature.match(lines[0]): 802 elif signature.match(lines[0]):
798 break 803 break
799 804
800 # and add the section to the output 805 # and add the section to the output
801 l.append(section) 806 l.append(section)
802 return summary, '\n\n'.join(l) 807 # we only set content for those who want to delete cruft from the
808 # message body, otherwise the body is left untouched.
809 if not keep_body:
810 content = '\n\n'.join(l)
811 return summary, content
803 812
804 # 813 #
805 # $Log: not supported by cvs2svn $ 814 # $Log: not supported by cvs2svn $
815 # Revision 1.66 2002/03/14 23:59:24 richard
816 # . #517734 ] web header customisation is obscure
817 #
806 # Revision 1.65 2002/02/15 00:13:38 richard 818 # Revision 1.65 2002/02/15 00:13:38 richard
807 # . #503204 ] mailgw needs a default class 819 # . #503204 ] mailgw needs a default class
808 # - partially done - the setting of additional properties can wait for a 820 # - partially done - the setting of additional properties can wait for a
809 # better configuration system. 821 # better configuration system.
810 # 822 #

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