def decorate_message(self, event, message, charset):
        domain = self.config.get('notification', 'smtp_from') or \
            self.config.get('notification', 'smtp_replyto')
        ticket = event.target

        mid = '<ticketref{}@{}>'.format(ticket.id, domain)
        if 'References' in message:
            mid += ' ' + message['References']
        set_header(message, 'References', mid, charset)
Exemplo n.º 2
0
 def decorate_message(self, event, message, charset):
     if event.realm == 'ticket' and event.category != 'created':
         rows = self.env.db_query("""
                 SELECT messageid FROM messageid WHERE ticket=%s
                 """, (event.target.id,))
         if rows:
             msgid = rows[0][0]
             set_header(message, 'In-Reply-To', msgid, charset)
             set_header(message, 'References', msgid, charset)
Exemplo n.º 3
0
 def decorate_message(self, event, message, charset):
     if event.realm == 'ticket' and event.category != 'created':
         rows = self.env.db_query(
             """
                 SELECT messageid FROM messageid WHERE ticket=%s
                 """, (event.target.id, ))
         if rows:
             msgid = rows[0][0]
             set_header(message, 'In-Reply-To', msgid, charset)
             set_header(message, 'References', msgid, charset)
Exemplo n.º 4
0
 def decorate_message(self, event, message, charset):
     if event.realm != 'ticket':
         return
     if event.category == 'batchmodify':
         notify = BatchTicketNotifyEmail(self.env)
         tickets = event.target
         tickets_descr = ', '.join(['#%s' % t for t in tickets])
         subject = notify.format_subj(tickets_descr)
     else:
         notify = TicketNotifyEmail(self.env)
         ticket = event.target
         notify.ticket = ticket
         summary = ticket['summary']
         from trac.ticket.web_ui import TicketModule
         for change in TicketModule(self.env) \
                       .grouped_changelog_entries(ticket, when=event.time):
             if 'summary' in change['fields']:
                 values = change['fields']['summary']
                 summary = "%s (was: %s)" % (values['new'], values['old'])
         subject = notify.format_subj(summary, event.category == 'created')
         url = self.env.abs_href.ticket(ticket.id)
         if event.category != 'created':
             cnum = ticket.get_comment_number(event.time)
             if cnum is not None:
                 url += '#comment:%d' % cnum
         set_header(message, 'X-Trac-Ticket-ID', ticket.id, charset)
         set_header(message, 'X-Trac-Ticket-URL', url, charset)
     set_header(message, 'Subject', subject, charset)
Exemplo n.º 5
0
 def decorate_message(self, event, message, charset):
     if event.realm != 'ticket':
         return
     if event.category == 'batchmodify':
         notify = BatchTicketNotifyEmail(self.env)
         tickets = event.target
         tickets_descr = ', '.join(['#%s' % t for t in tickets])
         subject = notify.format_subj(tickets_descr)
     else:
         notify = TicketNotifyEmail(self.env)
         ticket = event.target
         notify.ticket = ticket
         summary = ticket['summary']
         from trac.ticket.web_ui import TicketModule
         for change in TicketModule(self.env) \
                       .grouped_changelog_entries(ticket, when=event.time):
             if 'summary' in change['fields']:
                 values = change['fields']['summary']
                 summary = "%s (was: %s)" % (values['new'], values['old'])
         subject = notify.format_subj(summary, event.category == 'created')
         url = self.env.abs_href.ticket(ticket.id)
         if event.category != 'created':
             cnum = ticket.get_comment_number(event.time)
             if cnum is not None:
                 url += '#comment:%d' % cnum
         set_header(message, 'X-Trac-Ticket-ID', ticket.id, charset)
         set_header(message, 'X-Trac-Ticket-URL', url, charset)
     set_header(message, 'Subject', subject, charset)
Exemplo n.º 6
0
 def decorate_message(self, event, message, charset):
     if event.realm != 'ticket':
         return
     if event.category == 'batchmodify':
         notify = BatchTicketNotifyEmail(self.env)
         tickets = event.target
         tickets_descr = ', '.join(['#%s' % t for t in tickets])
         subject = notify.format_subj(tickets_descr)
     else:
         notify = TicketNotifyEmail(self.env)
         ticket = event.target
         notify.ticket = ticket
         summary = ticket['summary']
         subject = notify.format_subj(summary, event.category == 'created')
         url = self.env.abs_href.ticket(ticket.id)
         if event.category != 'created':
             cnum = ticket.get_comment_number(event.time)
             if cnum is not None:
                 url += '#comment:%d' % cnum
         set_header(message, 'X-Trac-Ticket-ID', ticket.id, charset)
         set_header(message, 'X-Trac-Ticket-URL', url, charset)
     set_header(message, 'Subject', subject, charset)
Exemplo n.º 7
0
 def decorate_message(self, event, message, charset):
     if event.realm != 'ticket':
         return
     from_email = self._get_from_email(event)
     if event.category == 'batchmodify':
         tickets = sort_tickets_by_priority(self.env, event.target)
         subject = self._format_subj_batchmodify(tickets)
         targetid = ','.join(map(str, tickets))
         msgid = self._get_message_id(targetid, from_email, event.time)
     else:
         subject = self._format_subj(event)
         ticket = event.target
         targetid = '%08d' % ticket.id
         more = ticket['reporter'] or ''
         msgid = self._get_message_id(targetid, from_email, None, more)
         url = self.env.abs_href.ticket(ticket.id)
         if event.category != 'created':
             set_header(message, 'In-Reply-To', msgid, charset)
             set_header(message, 'References', msgid, charset)
             msgid = self._get_message_id(targetid, from_email, event.time,
                                          more)
             cnum = ticket.get_comment_number(event.time)
             if cnum is not None:
                 url += '#comment:%d' % cnum
         set_header(message, 'X-Trac-Ticket-ID', ticket.id, charset)
         set_header(message, 'X-Trac-Ticket-URL', url, charset)
     set_header(message, 'Subject', subject, charset)
     set_header(message, 'Message-ID', msgid, charset)
Exemplo n.º 8
0
 def decorate_message(self, event, message, charset):
     if event.realm != 'ticket':
         return
     from_email = self._get_from_email(event)
     if event.category == 'batchmodify':
         tickets = sort_tickets_by_priority(self.env, event.target)
         subject = self._format_subj_batchmodify(tickets)
         targetid = ','.join(map(str, tickets))
         msgid = self._get_message_id(targetid, from_email, event.time)
     else:
         subject = self._format_subj(event)
         ticket = event.target
         targetid = '%08d' % ticket.id
         more = ticket['reporter'] or ''
         msgid = self._get_message_id(targetid, from_email, None, more)
         url = self.env.abs_href.ticket(ticket.id)
         if event.category != 'created':
             set_header(message, 'In-Reply-To', msgid, charset)
             set_header(message, 'References', msgid, charset)
             msgid = self._get_message_id(targetid, from_email, event.time,
                                          more)
             cnum = ticket.get_comment_number(event.time)
             if cnum is not None:
                 url += '#comment:%d' % cnum
         set_header(message, 'X-Trac-Ticket-ID', ticket.id, charset)
         set_header(message, 'X-Trac-Ticket-URL', url, charset)
         # When owner, reporter and updater are listed in the Cc header,
         # move the address to To header.
         if NotificationSystem(self.env).use_public_cc:
             to_addrs = set()
             matcher = RecipientMatcher(self.env)
             for rcpt in ticket['owner'], ticket['reporter'], event.author:
                 rcpt = matcher.match_recipient(rcpt)
                 if not rcpt:
                     continue
                 addr = rcpt[2]
                 if addr:
                     to_addrs.add(addr)
             if to_addrs:
                 cc_addrs = get_message_addresses(message, 'Cc')
                 to_addrs &= set(addr for name, addr in cc_addrs)
             if to_addrs:
                 cc_header = ', '.join(
                     create_header('Cc', (name, addr), charset)
                     for name, addr in cc_addrs if addr not in to_addrs)
                 if cc_header:
                     set_header(message, 'Cc', cc_header, charset)
                 elif 'Cc' in message:
                     del message['Cc']
                 to_header = ', '.join(sorted(to_addrs))
                 set_header(message, 'To', to_header, charset)
     set_header(message, 'Subject', subject, charset)
     set_header(message, 'Message-ID', msgid, charset)