def decorate_message(self, event, message, decorates=None): if event.realm == 'ticket': if 'status' in event.changes: action = 'Status -> %s' % (event.target['status']) template = NewTextTemplate( self.ticket_email_subject.encode('utf8')) # Create a fallback for invalid custom Genshi template in option. default_template = NewTextTemplate( Option.registry[ ('announcer', 'ticket_email_subject') ].default.encode('utf8')) try: subject = template.generate( ticket=event.target, event=event, action=event.category ).render('text', encoding=None) except TemplateError: # Use fallback template. subject = default_template.generate( ticket=event.target, event=event, action=event.category ).render('text', encoding=None) prefix = self.config.get('announcer', 'email_subject_prefix') if prefix == '__default__': prefix = '[%s] ' % self.env.project_name if prefix: subject = "%s%s" % (prefix, subject) if event.category != 'created': subject = 'Re: %s' % subject set_header(message, 'Subject', subject) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): if event.realm == "acct_mgr": prjname = self.env.project_name subject = '[%s] %s: %s' \ % (prjname, event.category, event.username) set_header(message, 'Subject', subject) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): if event.realm == 'ticket': for k in ('id', 'priority', 'severity'): name = 'X-Announcement-%s'%k.capitalize() set_header(message, name, event.target[k]) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): if event.realm == 'ticket': for k in ('id', 'priority', 'severity'): name = 'X-Announcement-%s' % k.capitalize() set_header(message, name, event.target[k]) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): if event.realm == 'ticket': if 'status' in event.changes: action = 'Status -> %s' % (event.target['status']) template = NewTextTemplate( self.ticket_email_subject.encode('utf8')) # Create a fallback for invalid custom Genshi template in option. default_template = NewTextTemplate(Option.registry[( 'announcer', 'ticket_email_subject')].default.encode('utf8')) try: subject = template.generate(ticket=event.target, event=event, action=event.category).render( 'text', encoding=None) except TemplateError: # Use fallback template. subject = default_template.generate( ticket=event.target, event=event, action=event.category).render('text', encoding=None) prefix = self.config.get('announcer', 'email_subject_prefix') if prefix == '__default__': prefix = '[%s] ' % self.env.project_name if prefix: subject = "%s%s" % (prefix, subject) if event.category != 'created': subject = 'Re: %s' % subject set_header(message, 'Subject', subject) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): if event.realm == "blog": template = NewTextTemplate(self.blog_email_subject.encode('utf8')) subject = template.generate(blog=event.blog_post, action=event.category).render( 'text', encoding=None) set_header(message, 'Subject', subject) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): if event.realm == "blog": template = NewTextTemplate(self.blog_email_subject.encode('utf8')) subject = template.generate( blog=event.blog_post, action=event.category ).render('text', encoding=None) set_header(message, 'Subject', subject) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): for k, v in {'Cc': self.always_cc, 'Bcc': self.always_bcc}.items(): if v: self.log.debug("StaticEmailDecorator added '%s' because of " "rule: email_always_%s", v, k.lower()), if message[k] and str(message[k]).split(','): recipients = ", ".join([str(message[k]), v]) else: recipients = v set_header(message, k, recipients) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorators): mailer = 'AnnouncerPlugin v%s on Trac v%s' % (announcer_version, trac_version) set_header(message, 'Auto-Submitted', 'auto-generated') set_header(message, 'Precedence', 'bulk') set_header(message, 'X-Announcer-Version', announcer_version) set_header(message, 'X-Mailer', mailer) set_header(message, 'X-Trac-Announcement-Realm', event.realm) set_header(message, 'X-Trac-Project', self.env.project_name) set_header(message, 'X-Trac-Version', trac_version) return next_decorator(event, message, decorators)
def decorate_message(self, event, message, decorates=None): for k, v in {'Cc': self.always_cc, 'Bcc': self.always_bcc}.items(): if v: self.log.debug("StaticEmailDecorator added '%s' " "because of rule: email_always_%s" % (v, k.lower())), if message[k] and len(str(message[k]).split(',')) > 0: recips = ", ".join([str(message[k]), v]) else: recips = v set_header(message, k, recips) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): if event.realm == "bitten": build_id = str(event.target.id) build_link = self._build_link(event.target) subject = '[%s Build] %s [%s] %s' % (self.readable_states.get( event.target.status, event.target.status), self.env.project_name, event.target.rev, event.target.config) set_header(message, 'X-Trac-Build-ID', build_id) set_header(message, 'X-Trac-Build-URL', build_link) set_header(message, 'Subject', subject) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorators): mailer = 'AnnouncerPlugin v%s on Trac v%s' % ( announcer_version, trac_version ) set_header(message, 'Auto-Submitted', 'auto-generated') set_header(message, 'Precedence', 'bulk') set_header(message, 'X-Announcer-Version', announcer_version) set_header(message, 'X-Mailer', mailer) set_header(message, 'X-Trac-Announcement-Realm', event.realm) set_header(message, 'X-Trac-Project', self.env.project_name) set_header(message, 'X-Trac-Version', trac_version) return next_decorator(event, message, decorators)
def decorate_message(self, event, message, decorates=None): if event.realm == "bitten": build_id = str(event.target.id) build_link = self._build_link(event.target) subject = "[%s Build] %s [%s] %s" % ( self.readable_states.get(event.target.status, event.target.status), self.env.project_name, event.target.rev, event.target.config, ) set_header(message, "X-Trac-Build-ID", build_id) set_header(message, "X-Trac-Build-URL", build_link) set_header(message, "Subject", subject) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): """ Added headers to the outgoing email to track it's relationship with a resource. Reply-To will encode a UID as a email parameter so replies to the resource announcement can be handled by an ITracGateEmailHandler. """ if event.realm in self.reply_to_realms: name, email_addr = parseaddr(str(message['Reply-To'])) uid = uid_encode(self.env.abs_href(), event.realm, event.target) m = ADDR_REGEX.match(email_addr) new_email_addr = '%s+%s@%s'%(m.group(1), uid, m.group(2)) new_addr = formataddr((name, new_email_addr)) set_header(message, 'Reply-To', new_email_addr) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): if event.realm == 'wiki': template = NewTextTemplate(self.wiki_email_subject.encode('utf8')) subject = template.generate(page=event.target, event=event, action=event.category).render( 'text', encoding=None) prefix = self.config.get('announcer', 'email_subject_prefix') if prefix == '__default__': prefix = '[%s] ' % self.env.project_name if prefix: subject = "%s%s" % (prefix, subject) if event.category != 'created': subject = 'Re: %s' % subject set_header(message, 'Subject', subject) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): if event.realm == 'wiki': template = NewTextTemplate(self.wiki_email_subject.encode('utf8')) subject = template.generate( page=event.target, event=event, action=event.category ).render('text', encoding=None) prefix = self.config.get('announcer', 'email_subject_prefix') if prefix == '__default__': prefix = '[%s] ' % self.env.project_name if prefix: subject = "%s%s" % (prefix, subject) if event.category != 'created': subject = 'Re: %s' % subject set_header(message, 'Subject', subject) return next_decorator(event, message, decorates)
def decorate_message(self, event, message, decorates=None): """ Added headers to the outgoing email to track it's relationship with a ticket. References, In-Reply-To and Message-ID are just so email clients can make sense of the threads. """ if to_unicode(event.realm) in self.supported_realms: uid = uid_encode(self.env.abs_href(), event.realm, event.target) email_from = self.config.get('announcer', 'email_from', 'localhost') _, email_addr = parseaddr(email_from) host = re.sub('^.+@', '', email_addr) mymsgid = msgid(uid, host) if event.category == 'created': set_header(message, 'Message-ID', mymsgid) else: set_header(message, 'In-Reply-To', mymsgid) set_header(message, 'References', mymsgid) return next_decorator(event, message, decorates)