Changeset 633
- Timestamp:
- 08/06/13 16:02:40 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/email2trac.py.in
r631 r633 75 75 m = None 76 76 77 # This is to for the function AlwaysNotifyReporter78 sender_email = None79 80 # This is to for the function set_reply_to_fiedl81 REPLY_TO_ADDRESS = None82 83 84 85 77 class SaraDict(UserDict.UserDict): 86 78 def __init__(self, dictin = None): … … 128 120 def __iter__(self): 129 121 return iter(self.data.keys()) 122 123 130 124 131 125 class TicketEmailParser(object): … … 2416 2410 self.logger.debug('function notify()') 2417 2411 2418 if self.parameters.notify_reporter: 2419 self.logger.debug('\t Notify reporter set') 2420 global sender_email 2421 sender_email = self.email_addr 2422 2423 self.logger.debug('\t Using Email2TracNotification function AlwaysNotifyReporter') 2424 import trac.notification as Email2TracNotification 2425 Email2TracNotification.Notify.notify = AlwaysNotifyReporter 2426 2412 2413 #if self.parameters.notification_replyto_rewrite: 2414 # global REPLY_TO_ADDRESS 2415 # dummy = self.smtp_replyto.split('@') 2416 2417 # if len(dummy) > 1: 2418 # REPLY_TO_ADDRESS = '%s+%s@%s' %(dummy[0], self.id, dummy[1]) 2419 # else: 2420 # REPLY_TO_ADDRESS = '%s+%s' %(dummy[0], self.id) 2421 2422 # import trac.notification as Email2TracNotification 2423 # Email2TracNotification.Notify.notify = set_reply_to_field 2424 2425 class Email2TracNotifyEmail(TicketNotifyEmail): 2426 2427 def __init__(self, env): 2428 TicketNotifyEmail.__init__(self, env) 2429 self.email2trac_notify_reporter = None 2430 self.email2trac_replyto = None 2431 2432 def send(self, torcpts, ccrcpts): 2433 #print 'Yes this works' 2434 dest = self.reporter or 'anonymous' 2435 hdrs = {} 2436 hdrs['Message-ID'] = self.get_message_id(dest, self.modtime) 2437 hdrs['X-Trac-Ticket-ID'] = str(self.ticket.id) 2438 hdrs['X-Trac-Ticket-URL'] = self.data['ticket']['link'] 2439 if not self.newticket: 2440 msgid = self.get_message_id(dest) 2441 hdrs['In-Reply-To'] = msgid 2442 hdrs['References'] = msgid 2443 2444 2445 if self.email2trac_notify_reporter: 2446 if not self.email2trac_notify_reporter in torcpts: 2447 torcpts.append(sender_email) 2448 2449 if self.email2trac_replyto: 2450 # use to rewrite reply to 2451 # hdrs does not work, multiple reply addresses 2452 #hdrs['Reply-To'] = 'bas.van.der.vlies@gmail.com' 2453 self.replyto_email = self.email2trac_replyto 2427 2454 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 2455 NotifyEmail.send(self, torcpts, ccrcpts, hdrs) 2439 2456 2440 2457 if self.parameters.dry_run : … … 2443 2460 try: 2444 2461 2445 #from trac.ticket.notification import TicketNotificationSystem2446 #tn_sys = TicketNotificationSystem(self.env)2447 #print tn_sys2448 #print tn_sys.__dict__2449 #sys.exit(0)2450 2451 2462 ## create false {abs_}href properties, to trick Notify() 2452 2463 # … … 2455 2466 self.env.href = Href(self.get_config('project', 'url')) 2456 2467 2457 tn = TicketNotifyEmail(self.env) 2468 tn = Email2TracNotifyEmail(self.env) 2469 2470 ## additionally append sender (regardeless of settings in trac.ini) 2471 # 2472 if self.parameters.notify_reporter: 2473 2474 self.logger.debug('\t Notify reporter set') 2475 2476 if not self.email_header_acl('notify_reporter_black_list', self.email_addr, False): 2477 tn.email2trac_notify_reporter = self.email_addr 2478 2479 if self.parameters.notify_replyto_rewrite: 2480 2481 self.logger.debug('\t Notify replyto rewrite set') 2482 2483 action, value = self.parameters.notify_replyto_rewrite.split(':') 2484 2485 if action in ['use_mail_domain']: 2486 self.logger.debug('\t\t use_mail_domain:%s'i %value) 2487 tn.email2trac_replyto = '%s@%s' %(self.id, value) 2488 2489 elif action in ['use_trac_smtp_replyto']: 2490 self.logger.debug('\t\t use_trac_smtp_replyto delimiter:%s'i %value) 2491 dummy = self.smtp_replyto.split('@') 2492 if len(dummy) > 1: 2493 tn.email2trac_replyto = '%s%s%s@%s' %(dummy[0], value, self.id, dummy[1]) 2494 else: 2495 tn.email2trac_replyto = '%s%s%s' %(dummy[0], value, self.id) 2458 2496 2459 2497 if self.parameters.alternate_notify_template: … … 2481 2519 ########## END Class Definition ######################################################## 2482 2520 2483 ########## Global Notificaition Function ################################################2484 def AlwaysNotifyReporter(self, resid):2485 """2486 Copy of def notify() to manipulate recipents to always include reporter for the2487 notification.2488 """2489 #print sender_email, resid2490 (torcpts, ccrcpts) = self.get_recipients(resid)2491 #print "get_recipients finished"2492 2493 if not tktparser.email_header_acl('notify_reporter_black_list', sender_email, False):2494 ## additionally append sender (regardeless of settings in trac.ini)2495 #2496 if not sender_email in torcpts:2497 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 2505 def set_reply_to_field(self, resid):2506 """2507 Copy of def notify() to manipulate recipents to always include reporter for the2508 notification.2509 """2510 print sender_email, resid, REPLY_TO_ADDRESS2511 (torcpts, ccrcpts) = self.get_recipients(resid)2512 2513 self.replyto_email = '%s' %(REPLY_TO_ADDRESS)2514 print self.replyto_email2515 2516 self.begin_send()2517 self.send(torcpts, ccrcpts)2518 self.finish_send()2519 2521 2520 2522 ########## Parse Config File ########################################################### … … 2653 2655 return logger 2654 2656 2657 ########## Own TicketNotifyEmail class ############################################################### 2655 2658 2656 2659 if __name__ == '__main__': … … 2763 2766 from trac.core import TracError 2764 2767 2765 elif version in ['0.11', '0.12', '0.13', '1.0' ]:2768 elif version in ['0.11', '0.12', '0.13', '1.0', '1.1']: 2766 2769 from trac import attachment 2767 2770 from trac import config as trac_config … … 2795 2798 # see http://projects.edgewall.com/trac/changeset/2799 2796 2799 from trac.ticket.notification import TicketNotifyEmail 2800 from trac.notification import NotifyEmail 2797 2801 2798 2802 else: … … 2833 2837 2834 2838 sys.exit(1) 2839 2835 2840 # EOB
Note: See TracChangeset
for help on using the changeset viewer.