Ticket #116: email2trac_blog.3.patch
File email2trac_blog.3.patch, 2.5 KB (added by lucas.eisenzimmer@…, 15 years ago) |
---|
-
.py
old new 581 581 else: 582 582 subject = self.email_to_unicode(m['Subject']) 583 583 584 # [hic] #1529: Re: LRZ585 # [hic] #1529?owner=bas,priority=medium: Re: LRZ586 #587 TICKET_RE = re.compile(r"""588 (?P<ticketnr>[#][0-9]+:)589 |(?P<ticketnr_fields>[#][\d]+\?.*?:)590 """, re.VERBOSE)591 592 result = TICKET_RE.search(subject)593 if not result:594 return False595 596 584 # Must we update ticket fields 597 585 # 598 586 update_fields = dict() … … 839 827 else: 840 828 self.notification = 0 841 829 842 # Must we update existing tickets 843 # 844 if self.TICKET_UPDATE > 0: 845 if self.ticket_update(m, spam_msg): 846 return True 830 # Find out if this is a ticket or a blog 831 if not m['Subject']: 832 return False 833 else: 834 subject = self.email_to_unicode(m['Subject']) 835 836 TICKET_RE=re.compile(r""" 837 (?P<blog>blog:(?P<blog_id>\w*)) 838 |(?P<ticket>\#(?P<ticket_id>[0-9]*):) 839 """, re.VERBOSE) 840 841 result = TICKET_RE.search(subject) 842 843 844 print "action:" 845 if result: 846 if result.group('blog'): 847 # instantiate blog core 848 blog = FullBlogCore(self.env) 849 req = '' 850 851 if result.group('blog_id'): 852 # update blog 853 comment = BlogComment(self.env, result.group('blog_id')) 854 comment.author = self.author 855 comment.comment = self.get_body_text(m) 856 857 blog.create_comment(req, comment) 858 859 else: 860 # create blog 861 import time 862 post = BlogPost(self.env, 'blog_'+time.strftime("%Y%m%d%H%M%S", time.gmtime())) 863 #post = BlogPost(self.env, blog._get_default_postname(self.env)) 864 865 post.author = self.author 866 post.title = self.email_to_unicode(m['Subject']) 867 post.body = self.get_body_text(m) 847 868 848 self.new_ticket(m, spam_msg) 869 blog.create_post(req, post, self.author, u'Created by email2trac', False) 870 871 else: 872 if result.group('ticket_id') and self.TICKET_UPDATE: 873 # update ticket 874 self.ticket_update(m, spam_msg) 875 print "ticket update" 876 else: 877 # create ticket 878 self.new_ticket(m, spam_msg) 879 print "ticket create" 880 else: 881 print "nothing" 849 882 850 883 def strip_signature(self, text): 851 884 """ … … 1266 1299 from trac.web.href import Href 1267 1300 from trac import config as trac_config 1268 1301 from trac import util 1302 1303 # blog enhancements 1304 from tracfullblog.core import FullBlogCore 1305 from tracfullblog.model import BlogPost, BlogComment 1306 1269 1307 # 1270 1308 # return util.text.to_unicode(str) 1271 1309 #