Ticket #379: email2trac_ignore_attachments.diff

File email2trac_ignore_attachments.diff, 1.9 KB (added by anonymous, 8 years ago)
  • c:/trac/email2trac.

    old new  
    319319
    320320        return False
    321321
     322    def email_attachment_ignored(self, attachment_name):
     323        """
     324        This function will check if the attachment should be ignored.
     325        """
     326        self.logger.debug('function email_attachment_acl: %s' % attachment_name)
     327       
     328        try:
     329            ignored_attachments = self.parameters['ignored_attachments']
     330           
     331            # Check empty string
     332            #
     333            if not ignored_attachments:
     334                return false #not ignored
     335           
     336        except KeyError, detail:
     337            self.logger.debug('\t %s not defined, all messages are allowed.' % ('ignored_attachments'))
     338
     339            return false #not ignored
     340
     341        ignored_attachments = string.split(ignored_attachments, ',')
     342       
     343        for entry in ignored_attachments:
     344            if attachment_name == entry:
     345                return True #ignore this attachment
     346
    322347    def email_header_txt(self, m):
    323348        """
    324349        Display To and CC addresses in description field
     
    13851410               
    13861411            (original, filename, part) = item
    13871412
     1413            # Skip black-listed attachments
     1414            if self.email_attachment_ignored(filename):
     1415                continue
     1416           
    13881417            ## We have to determine the size so we use this temporary solution.
    13891418            #
    13901419            path, fd =  util.create_unique_file(os.path.join(self.parameters.tmpdir, 'email2trac_tmp.att'))
     
    23342363
    23352364            (original, filename, part) = part
    23362365            inline = self.inline_part(part)
     2366
     2367            if self.email_attachment_ignored(filename):
     2368                continue
    23372369
    23382370            ## Skip generation of attachment link if html is converted to text
    23392371            #