Changeset 631


Ignore:
Timestamp:
06/21/13 17:41:13 (11 years ago)
Author:
bas
Message:

We can now support name+id@… addresses:

  • recipient_delimiter: +

wrote a simple notication function that sets the reply to field of a mail to: name+id@…

  • notification_replyto_rewrite: 1

For each bug there will be an uniqye address

Still some work to be done:

see #297

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/email2trac.py.in

    r630 r631  
    7878sender_email = None
    7979
     80# This is to for the function set_reply_to_fiedl
     81REPLY_TO_ADDRESS = None
     82
     83
     84
    8085class SaraDict(UserDict.UserDict):
    8186    def __init__(self, dictin = None):
     
    222227        self.trac_smtp_from = self.get_config('notification', 'smtp_from')
    223228        self.smtp_default_domain = self.get_config('notification', 'smtp_default_domain')
     229        self.smtp_replyto = self.get_config('notification', 'smtp_replyto')
    224230
    225231
     
    17791785        self.logger.info('subject: %s' %repr(subject))
    17801786
     1787        ## First try the new method and then fall back to old method
     1788        #
     1789        if not self.parse_delivered_to_field(m, subject, spam_msg):
     1790            self.parse_subject_field(m, subject, spam_msg)
     1791
     1792    def parse_delivered_to_field(self, m, subject, spam_msg):
     1793        """
     1794        """
     1795        self.logger.debug('function parse_delivered_to_field')
     1796
    17811797        ## Ticket id is in Delivered-To Field. Trac notify must send this
    1782         #
    1783         #try:
    1784         #    print self.parameters.project_name
    1785         #    print 'Delivered To', m['Delivered-To']
    1786         #    print self.parameters.to_parse_address_delimiter
    1787         #    id = m['Delivered-To'].split(self.parameters.to_parse_address_delimiter)[1]
    1788         #    print id
    1789         #    id = id.split('@')[0]
    1790         #    print id
    1791 #
    1792 #        except KeyError, detail:
    1793 #            pass
    1794 
     1798        #  eg: is+390@surfsara.nl
     1799        try:
     1800
     1801            #print self.parameters.project_name
     1802            self.logger.debug('Delivered To: %s' %m['Delivered-To'])
     1803
     1804            id = m['Delivered-To']
     1805            id = id.split(self.parameters.recipient_delimiter)[1]
     1806            id = id.split('@')[0]
     1807
     1808            self.logger.debug('\t Found ticket id: %s' %id)
     1809
     1810            if not self.ticket_update(m, id, spam_msg):
     1811                return False
     1812
     1813        except KeyError, detail:
     1814            pass
     1815        except IndexError, detail:
     1816            pass
     1817
     1818        return False
     1819
     1820    def parse_subject_field(self, m, subject, spam_msg):
     1821        """
     1822        """
     1823        self.logger.debug('function parse_subject_header')
    17951824
    17961825        ## [hic] #1529: Re: LRZ
     
    18011830            |(?P<reply>(?P<id>[#][\d]+)(?P<fields>\?.*)?:)
    18021831            '''
     1832
    18031833        ## Check if  FullBlogPlugin is installed
    18041834        #
     
    23952425            Email2TracNotification.Notify.notify = AlwaysNotifyReporter
    23962426
     2427       
     2428        if self.parameters.notification_replyto_rewrite:
     2429            global REPLY_TO_ADDRESS
     2430            dummy = self.smtp_replyto.split('@')
     2431           
     2432            if len(dummy) > 1:
     2433                REPLY_TO_ADDRESS = '%s+%s@%s' %(dummy[0], self.id, dummy[1])
     2434            else:
     2435                REPLY_TO_ADDRESS = '%s+%s' %(dummy[0], self.id)
     2436
     2437            import trac.notification as Email2TracNotification
     2438            Email2TracNotification.Notify.notify = set_reply_to_field
     2439
    23972440        if self.parameters.dry_run  :
    23982441                self.logger.info('DRY_RUN: self.notify(tkt, True) reporter = %s' %tkt['reporter'])
     
    24532496        if not sender_email in torcpts:
    24542497            torcpts.append(sender_email)
     2498
     2499    #self.replyto_email = "bas.van.der.vlies@gmail.com"
     2500
     2501    self.begin_send()
     2502    self.send(torcpts, ccrcpts)
     2503    self.finish_send()
     2504
     2505def set_reply_to_field(self, resid):
     2506    """
     2507    Copy of def notify() to manipulate recipents to always include reporter for the
     2508    notification.
     2509    """
     2510    print sender_email, resid, REPLY_TO_ADDRESS
     2511    (torcpts, ccrcpts) = self.get_recipients(resid)
     2512   
     2513    self.replyto_email = '%s' %(REPLY_TO_ADDRESS)
     2514    print self.replyto_email
    24552515
    24562516    self.begin_send()
  • trunk/msg.txt

    r606 r631  
    1 From basv@sara.nl  Wed Mar  8 15:29:17 2006
     1From bas.vandervlies@surfsara.nl  Wed Mar  8 15:29:17 2006
    22Return-Path: <basv@sara.nl>
    33X-Original-To: test@subtrac.sara.nl
     
    2828Test1234
    2929
    30 --
    31 ********************************************************************
    32 *                                                                  *
    33 *  Bas van der Vlies                     e-mail: basv@sara.nl      *
    34 *  SARA - Academic Computing Services    phone:  +31 20 592 8012   *
    35 *  Kruislaan 415                         fax:    +31 20 6683167    *
    36 *  1098 SJ Amsterdam                                               *
    37 *                                                                  *
    38 ********************************************************************
     30---
     31As of 1 January 2013, SARA has a new name: SURFsara.
     32
     33Bas van der Vlies
     34| Operations, Support & Development | SURFsara | Science Park 140 | 1098 XG  Amsterdam
     35| T +31 (0) 20 592 30 00 | bas.vandervlies@surfsara.nl | www.surfsara.nl |
    3936
    4037--------------070800080005060203060809
Note: See TracChangeset for help on using the changeset viewer.