Example #1
0
 def notify_unreachable_milestone(self, tickets):
     """
     Send a digest mail listing all tickets still opened in the milestone
     """
     self.populate_unreachable_tickets_data(tickets)
    
     NotifyEmail.notify(self, self.milestone, "Milestone %s still has opened ticket" % self.milestone)
Example #2
0
    def invite(self, context, forum = None, topic = None, recipients = []):
        # Store link to currently notifying forum.
        self.forum = forum
        self.topic = topic

        # Initialize template data.
        data = {}
        data['forum'] = self.forum
        data['topic'] = self.topic
        data['prefix'] = self.config.get('notification', 'smtp_subject_prefix')
        if data['prefix'] == '__default__':
            data['prefix'] = self.env.project_name
        self.data.update({'discussion' : data})

        # Which item notify about?
        if self.topic:
            self.topic['link'] = self.env.abs_href.discussion('topic',
              self.topic['id'])
            self.template_name = 'topic-invite-body.txt'
        elif self.forum:
            self.forum['link'] = self.env.abs_href.discussion('forum',
              self.forum['id'])
            self.template_name = 'forum-invite-body.txt'

        # Send e-mail to all subscribers.
        self.cc_recipients = recipients + self.config.getlist('discussion',
          'smtp_always_cc')

        # Render subject template and send notification.
        subject = (to_unicode(Chrome(self.env).render_template(context.req,
          self.topic and 'topic-invite-subject.txt' or
            'forum-invite-subject.txt', self.data, 'text/plain'))).strip()
        NotifyEmail.notify(self, id, subject)
Example #3
0
    def invite(self, context, forum = None, topic = None, recipients = []):
        # Store link to currently notifying forum.
        self.forum = forum
        self.topic = topic

        # Initialize template data.
        data = {}
        data['forum'] = self.forum
        data['topic'] = self.topic
        data['prefix'] = self.config.get('notification', 'smtp_subject_prefix')
        if data['prefix'] == '__default__':
            data['prefix'] = self.env.project_name
        self.data.update({'discussion' : data})

        # Which item notify about?
        if self.topic:
            self.topic['link'] = self.env.abs_href.discussion('topic',
              self.topic['id'])
            self.template_name = 'topic-invite-body.txt'
        elif self.forum:
            self.forum['link'] = self.env.abs_href.discussion('forum',
              self.forum['id'])
            self.template_name = 'forum-invite-body.txt'

        # Send e-mail to all subscribers.
        self.cc_recipients = recipients

        # Render subject template and send notification.
        subject = (to_unicode(Chrome(self.env).render_template(context.req,
          self.topic and 'topic-invite-subject.txt' or
            'forum-invite-subject.txt', self.data, 'text/plain'))).strip()
        NotifyEmail.notify(self, id, subject)
Example #4
0
 def notify(self, build):
     self.build = build
     self.data.update(self.template_data())
     subject = '[%s Build] %s [%s] %s' % (
         self.readable_states[build.status], self.env.project_name,
         self.build.rev, self.build.config)
     NotifyEmail.notify(self, self.build.id, subject)
Example #5
0
            def notifyTaskEvent(self, task_event_list):
                """
                Send task event by mail if recipients is defined in trac.ini
                """
                self.env.log.debug("notifying task event...")             
                if self.cronconf.get_email_notifier_task_recipient() :                                    
                    # prepare the data for the email content generation
                    mess = ""      
                    start = True
                    for event in task_event_list:
                        if start:                        
                            mess = mess + "task[%s]" % (event.task.getId(),)                       
                            mess = mess + "\nstarted at %d h %d" % (event.time.tm_hour, event.time.tm_min)
                            mess = mess + "\n"
                        else:
                            mess = mess + "ended at %d h %d" % (event.time.tm_hour, event.time.tm_min)
                            if (event.success):
                                mess = mess + "\nsuccess"
                            else:
                                mess = mess + "\nFAILURE"
                            mess = mess + "\n\n"
                        start = not start                            

                    self.data.update({
                                     "notify_body": mess,                                        
                                      })                                          
                    NotifyEmail.notify(self, None, "task event notification")
                else:
                    self.env.log.debug("no recipient for task event, aborting")
Example #6
0
        def notifyTaskEvent(self, task_event_list):
            """
                Send task event by mail if recipients is defined in trac.ini
                """
            self.env.log.debug("notifying task event...")
            if self.cronconf.get_email_notifier_task_recipient():
                # prepare the data for the email content generation
                mess = ""
                start = True
                for event in task_event_list:
                    if start:
                        mess = mess + "task[%s]" % (event.task.getId(), )
                        mess = mess + "\nstarted at %d h %d" % (
                            event.time.tm_hour, event.time.tm_min)
                        mess = mess + "\n"
                    else:
                        mess = mess + "ended at %d h %d" % (event.time.tm_hour,
                                                            event.time.tm_min)
                        if (event.success):
                            mess = mess + "\nsuccess"
                        else:
                            mess = mess + "\nFAILURE"
                        mess = mess + "\n\n"
                    start = not start

                self.data.update({
                    "notify_body": mess,
                })
                NotifyEmail.notify(self, None, "task event notification")
            else:
                self.env.log.debug("no recipient for task event, aborting")
Example #7
0
 def notify_opened_ticket(self, owner, tickets):
     """
     Send a digest mail to ticket owner
     about ticket still opened 
     """
     
     self.populate_unreachable_tickets_data(tickets)                           
     NotifyEmail.notify(self, owner, "Milestone %s still has opened ticket" % self.milestone)
Example #8
0
 def notify(self, build):
     self.build = build
     self.data.update(self.template_data())
     subject = '[%s Build] %s [%s] %s' % (self.readable_states[build.status],
                                          self.env.project_name,
                                          self.build.rev,
                                          self.build.config)
     NotifyEmail.notify(self, self.build.id, subject)
Example #9
0
            def notify_unreachable_milestone(self, tickets):
                """
                Send a digest mail listing all tickets still opened in the milestone
                """
                self.populate_unreachable_tickets_data(tickets)

                NotifyEmail.notify(
                    self, self.milestone,
                    "Milestone %s still has opened ticket" % self.milestone)
Example #10
0
 def notify(self, username, subject):
     # save the username for use in `get_smtp_address`
     self._username = username
     old_public_cc = self.config.getbool('notification', 'use_public_cc')
     # override public cc option so that the user's email is included in the To: field
     self.config.set('notification', 'use_public_cc', 'true')
     try:
         NotifyEmail.notify(self, username, subject)
     except Exception, e:
         raise NotificationError(e)
Example #11
0
            def notify_opened_ticket(self, owner, tickets):
                """
                Send a digest mail to ticket owner
                about ticket still opened 
                """

                self.populate_unreachable_tickets_data(tickets)
                NotifyEmail.notify(
                    self, owner,
                    "Milestone %s still has opened ticket" % self.milestone)
Example #12
0
 def notify(self, username, subject):
     # save the username for use in `get_smtp_address`
     self._username = username
     old_public_cc = self.config.getbool('notification', 'use_public_cc')
     # override public cc option so that the user's email is included in the To: field
     self.config.set('notification', 'use_public_cc', 'true')
     try:
         NotifyEmail.notify(self, username, subject)
     finally:
         self.config.set('notification', 'use_public_cc', old_public_cc)
Example #13
0
    def notify(self,
               action,
               page,
               version=None,
               time=None,
               comment=None,
               author=None,
               ipnr=None,
               redirect=False,
               old_name=None):
        self.page = page
        self.change_author = author
        self.time = time
        self.action = action
        self.version = version
        self.redirect = redirect
        self.old_name = old_name
        #        self.env.log.debug("Notify Action: %s", action)
        #        self.env.log.debug("Page time: %r, %s", time, time)

        if action == "added":
            self.newwiki = True

        self.data['name'] = page.name
        self.data['old_name'] = old_name
        self.data['redirect'] = redirect
        self.data['text'] = page.text
        self.data['version'] = version
        self.data['author'] = author
        self.data['comment'] = comment
        self.data['ip'] = ipnr
        self.data['action'] = action
        self.data['link'] = self.env.abs_href.wiki(page.name)
        self.data['linkdiff'] = self.env.abs_href.wiki(page.name,
                                                       action='diff',
                                                       version=page.version)
        if page.version > 0 and action == 'modified':
            diff = diff_header % {
                'name': self.page.name,
                'version': self.page.version,
                'oldversion': self.page.version - 1
            }
            oldpage = WikiPage(self.env, page.name, page.version - 1)
            self.data["oldversion"] = oldpage.version
            self.data["oldtext"] = oldpage.text
            for line in unified_diff(oldpage.text.splitlines(),
                                     page.text.splitlines(),
                                     context=3):
                diff += "%s\n" % line
                self.wikidiff = diff
        self.data["wikidiff"] = self.wikidiff

        subject = self.format_subject(action.replace('_', ' '))

        NotifyEmail.notify(self, page.name, subject)
Example #14
0
    def notify(self, username, password):
        # save the username for use in `get_smtp_address`
        self._username = username
        self.hdf['account.username'] = username
        self.hdf['account.password'] = password
        self.hdf['login.link'] = self.env.abs_href.login()

        projname = self.config.get('project', 'name')
        subject = '[%s] Trac password reset for user: %s' % (projname, username)

        NotifyEmail.notify(self, username, subject)
Example #15
0
    def notify(self, to, key):
        addr = self.get_smtp_address(to)
        if addr is None:
            raise TracError('Invalid email address %s' % to)

        self.hdf['to'] = addr
        self.hdf['key'] = key

        subject = 'TracBL API key for %s' % addr

        NotifyEmail.notify(self, addr, subject)
Example #16
0
 def notify(self, build_info):
     self.build_info = build_info
     self.data = self.build_info
     subject = '[%s Build] %s [%s] %s' % (self.build_info.status,
             self.env.project_name,
             self.build_info.changeset,
             self.build_info.config)
     stream = self.template.generate(**self.data)
     body = stream.render('text')
     self.env.log.debug('notification: %s' % body )
     NotifyEmail.notify(self, self.build_info.id, subject)
Example #17
0
 def remind(self, tiketsByReporter):
     """
     Send a digest mail to the reporter to remind them
     of those orphaned tickets
     """
     for reporter in tiketsByReporter.keys():  
         # prepare the data for the email content generation                      
         self.data.update({
                           "ticket_count": len(tiketsByReporter[owner]),
                           "delay": delay
                           })                                          
         NotifyEmail.notify(self, reporter, "orphaned ticket notification")
Example #18
0
 def remind(self, tiketsByOwner):
     """
     Send a digest mail to ticket owner to remind him of those
     sleeping tickets
     """
     for owner in tiketsByOwner.keys():  
         # prepare the data for the email content generation                      
         self.data.update({
                           "ticket_count": len(tiketsByOwner[owner]),
                           "delay": delay
                           })                                          
         NotifyEmail.notify(self, owner, "Sleeping ticket notification")
Example #19
0
 def notify(self, to, key):
     addr = self.get_smtp_address(to)
     if addr is None:
         raise TracError('Invalid email address %s'%to)
     
     
     self.hdf['to'] = addr
     self.hdf['key'] = key
     
     subject = 'TracBL API key for %s'%addr
     
     NotifyEmail.notify(self, addr, subject)
Example #20
0
    def notify(self, username, password):
        # save the username for use in `get_smtp_address`
        self._username = username
        self.hdf['account.username'] = username
        self.hdf['account.password'] = password
        self.hdf['login.link'] = self.env.abs_href.login()

        projname = self.config.get('project', 'name')
        subject = '[%s] Trac password reset for user: %s' % (projname,
                                                             username)

        NotifyEmail.notify(self, username, subject)
Example #21
0
 def remind(self, tiketsByReporter):
     """
     Send a digest mail to the reporter to remind them
     of those orphaned tickets
     """
     for reporter in tiketsByReporter.keys():  
         # prepare the data for the email content generation                      
         self.data.update({
                           "ticket_count": len(tiketsByReporter[owner]),
                           "delay": delay
                           })                                          
         NotifyEmail.notify(self, reporter, "orphaned ticket notification")
Example #22
0
 def remind(self, tiketsByOwner):
     """
     Send a digest mail to ticket owner to remind him of those
     sleeping tickets
     """
     for owner in tiketsByOwner.keys():  
         # prepare the data for the email content generation                      
         self.data.update({
                           "ticket_count": len(tiketsByOwner[owner]),
                           "delay": delay
                           })                                          
         NotifyEmail.notify(self, owner, "Sleeping ticket notification")
Example #23
0
 def notify(self, username, subject):
     # save the username for use in `get_smtp_address`
     self._username = username
     old_public_cc = self.config.getbool('notification', 'use_public_cc')
     # override public cc option so that the user's email is included in the To: field
     self.config.set('notification', 'use_public_cc', 'true')
     try:
         NotifyEmail.notify(self, username, subject)
     # DEVEL: Better use new 'finally' statement here, but
     #   still need to care for Python 2.4 (RHEL5.x) for now
     except:
         pass
     self.config.set('notification', 'use_public_cc', old_public_cc)
Example #24
0
 def notify(self, username, subject):
     # save the username for use in `get_smtp_address`
     self._username = username
     old_public_cc = self.config.getbool('notification', 'use_public_cc')
     # override public cc option so that the user's email is included in the To: field
     self.config.set('notification', 'use_public_cc', 'true')
     try:
         NotifyEmail.notify(self, username, subject)
     # DEVEL: Better use new 'finally' statement here, but
     #   still need to care for Python 2.4 (RHEL5.x) for now
     except:
         pass
     self.config.set('notification', 'use_public_cc', old_public_cc)
    def notify_attachment(self, ticket, author, filename, modtime, body):
        """Send ticket attachment notification (untranslated)"""
        t = deactivate()
        translated_fields = ticket.fields
        try:
            ticket.fields = TicketSystem(self.env).get_ticket_fields()

            self.ticket = ticket
            self.modtime = modtime
            self.newticket = False
            self.reporter = ''
            self.owner = ''

            link = self.env.abs_href.ticket(ticket.id)
            summary = self.ticket['summary']
            ticket_values = ticket.values.copy()
            ticket_values['id'] = ticket.id

            wrap_kargs = {
                'initial_indent': ' ',
                'subsequent_indent': ' ',
                'linesep': CRLF
            }
            if 'ambiwidth' in getargspec(wrap)[0]:
                wrap_kargs['ambiwidth'] = self.ambiwidth

            ticket_values['description'] = wrap(
                ticket_values.get('description', ''),
                self.COLS,
                **wrap_kargs
            )

            ticket_values['new'] = self.newticket
            ticket_values['link'] = link
            subject = 'Re: ' + self.format_subj(summary)
            author = obfuscate_email_address(author)
            change = { 'author': author }

            self.data.update({
                'ticket_props': self.format_props(),
                'ticket_body_hdr': self.format_hdr(),
                'subject': subject,
                'ticket': ticket_values,
                'change': change,
                'changes_body': body,
                })

            NotifyEmail.notify(self, ticket.id, subject)
        finally:
            ticket.fields = translated_fields
            reactivate(t)
Example #26
0
    def notify(self, username, action):
        self.data.update({
            'account': {
                'username': username,
                'action': action
            },
            'login': {
                'link': self.env.abs_href.login(),
            }
        })

        projname = self.config.get('project', 'name')
        subject = '[%s] %s: %s' % (projname, action, username)

        NotifyEmail.notify(self, username, subject)
Example #27
0
    def notify(self, username, action):
        self.data.update({
            'account': {
                'username': username,
                'action': action
            },
            'login': {
                'link': self.env.abs_href.login(),
            }
        })

        projname = self.config.get('project', 'name')
        subject = '[%s] %s: %s' % (projname, action, username)

        NotifyEmail.notify(self, username, subject)
Example #28
0
    def notify(self,
               blog,
               action,
               version=None,
               time=None,
               comment=None,
               author=None):

        # Don't notify if action is explicitly omitted from notification_actions
        if self.notification_actions != [] and \
           action not in self.notification_actions:
            self.env.log.info('No notification sent because action is omitted ' \
                              'from notification_actions option list')
            return

        # Don't notify if post has one of the specified categories
        for category in blog.category_list:
            if category in self.no_notification_categories:
                self.env.log.info('No notification sent because there are one ' \
                                  'or more matches between post\'s categories list ' \
                                  'and no_notification_categories option list')
                return

        self.blog = blog
        self.change_author = author
        self.time = time
        self.action = action
        self.version = version

        self.data['name'] = blog.name
        self.data['title'] = blog.title
        self.data['body'] = blog.body
        self.data['comment'] = comment
        self.data['version'] = version
        self.data['author'] = author
        self.data['action'] = action
        self.data['time'] = format_datetime(time, '%Y-%m-%d %H:%M')
        self.data['url'] = self.env.abs_href.blog(blog.name)
        self.data['project'] = {
            'name': self.env.project_name,
            'url': self.env.project_url,
            'description': self.env.project_description
        }

        subject = self.format_subject()

        NotifyEmail.notify(self, blog.name, subject)
Example #29
0
    def notify(self, comment):
        self.comment_author = self._get_author_name(comment)

        self.data.update({
            "comment": comment,
            "comment_url": self.env.abs_href() + comment.href(),
            "project_url": self.env.project_url or self.env.abs_href(),
        })

        projname = self.config.get("project", "name")
        subject = "Re: [%s] %s" % (projname, comment.link_text())

        try:
            NotifyEmail.notify(self, comment, subject)
        except Exception, e:
            self.env.log.error("Failure sending notification on creation of "
                               "comment #%d: %s", comment.id, e)
    def notify(self, username, action):
        self.data.update({
            'account': {
                'username': username,
                'action': action
            },
            'login': {
                'link': self.env.abs_href.login(),
            }
        })

        projname = self.config.get('project', 'name')
        subject = '[%s] %s: %s' % (projname, action, username)

        try:
            NotifyEmail.notify(self, username, subject)
        except Exception, e:
            # Enable dedicated, graceful handling of notification issues.
            raise NotificationError(e)
Example #31
0
    def notify(self, username, action):
        self.data.update({
            'account': {
                'username': username,
                'action': action
            },
            'login': {
                'link': self.env.abs_href.login(),
            }
        })

        projname = self.config.get('project', 'name')
        subject = '[%s] %s: %s' % (projname, action, username)

        try:
            NotifyEmail.notify(self, username, subject)
        except Exception, e:
            # Enable dedicated, graceful handling of notification issues.
            raise NotificationError(e)
Example #32
0
 def _notify(self, tickets, new_values, comment, action, author):
     self.tickets = tickets
     changes_body = ''
     self.reporter = ''
     self.owner = ''
     changes_descr = '\n'.join(['%s to %s' % (prop, val)
                               for (prop, val) in new_values.iteritems()])
     tickets_descr = ', '.join(['#%s' % t for t in tickets])
     subject = self.format_subj(tickets_descr)
     link = self.env.abs_href.query(id=','.join([str(t) for t in tickets]))
     self.data.update({
         'tickets_descr': tickets_descr,
         'changes_descr': changes_descr,
         'comment': comment,
         'action': action,
         'author': author,
         'subject': subject,
         'ticket_query_link': link,
         })
     NotifyEmail.notify(self, tickets, subject, author)
Example #33
0
 def _notify(self, tickets, new_values, comment, action, author):
     self.tickets = tickets
     changes_body = ''
     self.reporter = ''
     self.owner = ''
     changes_descr = '\n'.join(['%s to %s' % (prop, val)
                               for (prop, val) in new_values.iteritems()])
     tickets_descr = ', '.join(['#%s' % t for t in tickets])
     subject = self.format_subj(tickets_descr)
     link = self.env.abs_href.query(id=','.join([str(t) for t in tickets]))
     self.data.update({
         'tickets_descr': tickets_descr,
         'changes_descr': changes_descr,
         'comment': comment,
         'action': action,
         'author': author,
         'subject': subject,
         'ticket_query_link': link,
         })
     NotifyEmail.notify(self, tickets, subject, author)
Example #34
0
    def notify(self, context, forum=None, topic=None, message=None):
        # Store link to currently notifying forum, topic and message.
        self.forum = forum
        self.topic = topic
        self.message = message

        # Initialize template data.
        data = {}
        data["forum"] = self.forum
        data["topic"] = self.topic
        data["message"] = self.message
        data["prefix"] = self.config.get("notification", "smtp_subject_prefix")
        if data["prefix"] == "__default__":
            data["prefix"] = self.env.project_name
        self.data.update({"discussion": data})

        # Which item notify about?
        if self.message:
            self.message["link"] = self.env.abs_href.discussion("message", self.message["id"])
            self.template_name = "message-notify-body.txt"
        elif self.topic:
            self.topic["link"] = self.env.abs_href.discussion("topic", self.topic["id"])
            self.template_name = "topic-notify-body.txt"

        # Send e-mail to all subscribers.
        self.cc_recipients = (
            forum["subscribers"] + topic["subscribers"] + self.config.getlist("discussion", "smtp_always_cc")
        )

        # Render subject template and send notification.
        subject = (
            to_unicode(
                Chrome(self.env).render_template(
                    context.req,
                    self.message and "message-notify-subject.txt" or "topic-notify-subject.txt",
                    self.data,
                    "text/plain",
                )
            )
        ).strip()
        NotifyEmail.notify(self, id, subject)
Example #35
0
    def notify(self, blog, action, version=None, time=None, comment=None,
               author=None):

        # Don't notify if action is explicitly omitted from notification_actions
        if self.notification_actions != [] and \
           action not in self.notification_actions:
            self.env.log.info('No notification sent because action is omitted ' \
                              'from notification_actions option list')
            return
        
        # Don't notify if post has one of the specified categories
        for category in blog.category_list:
            if category in self.no_notification_categories:
                self.env.log.info('No notification sent because there are one ' \
                                  'or more matches between post\'s categories list ' \
                                  'and no_notification_categories option list')
                return
        
        self.blog = blog
        self.change_author = author
        self.time = time
        self.action = action
        self.version = version

        self.data['name']= blog.name
        self.data['title']= blog.title
        self.data['body']= blog.body
        self.data['comment']= comment
        self.data['version']= version
        self.data['author']= author
        self.data['action']= action
        self.data['time'] = format_datetime(time, '%Y-%m-%d %H:%M')
        self.data['url']= self.env.abs_href.blog(blog.name)
        self.data['project'] = {'name': self.env.project_name, 
                                'url': self.env.project_url, 
                                'description': self.env.project_description}          
        
        subject = self.format_subject()

        NotifyEmail.notify(self, blog.name, subject)
Example #36
0
    def notify(self, comment):
        self.comment_author = self._get_author_name(comment)
        parsed_uri = urlparse(self.env.abs_href())
        domain = '{uri.scheme}://{uri.netloc}'.format(uri=parsed_uri)

        self.data.update({
            "comment":
            comment,
            "comment_url":
            domain + comment.href(),
            "project_url":
            self.env.project_url or self.env.abs_href(),
        })

        projname = self.config.get("project", "name")
        subject = "Re: [%s] %s" % (projname, comment.link_text())

        try:
            NotifyEmail.notify(self, comment, subject)
        except Exception, e:
            self.env.log.error(
                "Failure sending notification on creation of "
                "comment #%d: %s", comment.id, e)
Example #37
0
 def _generic_notify(self, relation, deleted):
     self.data.update(dict(
         created=not deleted,
         relation=relation,
     ))
     NotifyEmail.notify(self, '', '', '')
Example #38
0
 def notify(self, ticket, newticket=True, modtime=0):
     self.ticket = ticket
     self.modtime = modtime
     self.newticket = newticket
     self.ticket['description'] = wrap(self.ticket.values.get('description', ''),
                                       self.COLS, initial_indent=' ',
                                       subsequent_indent=' ', linesep=CRLF)
     self.reporter = ''
     self.owner = ''
     self.hdf.set_unescaped('email.ticket_props', self.format_props())
     self.hdf.set_unescaped('email.ticket_body_hdr', self.format_hdr())
     self.hdf['ticket.new'] = self.newticket
     subject = self.format_subj()
     link = self.env.abs_href.ticket(ticket.id)
     if not self.newticket:
         subject = 'Re: ' + subject
     self.hdf.set_unescaped('email.subject', subject)
     changes = ''
     if not self.newticket and modtime:  # Ticket change
         from trac.ticket.web_ui import TicketModule
         for change in TicketModule(self.env).grouped_changelog_entries(
             ticket, self.db, when=modtime):
             if not change['permanent']: # attachment with same time...
                 continue
             self.hdf.set_unescaped('ticket.change.author', 
                                    change['author'])
             self.hdf.set_unescaped('ticket.change.comment',
                                    wrap(change['comment'], self.COLS,
                                         ' ', ' ', CRLF))
             link += '#comment:%s' % str(change.get('cnum', ''))
             for field, values in change['fields'].iteritems():
                 old = values['old']
                 new = values['new']
                 pfx = 'ticket.change.%s' % field
                 newv = ''
                 if field == 'description':
                     new_descr = wrap(new, self.COLS, ' ', ' ', CRLF)
                     old_descr = wrap(old, self.COLS, '> ', '> ', CRLF)
                     old_descr = old_descr.replace(2*CRLF, CRLF + '>' + CRLF)
                     cdescr = CRLF
                     cdescr += 'Old description:' + 2*CRLF + old_descr + 2*CRLF
                     cdescr += 'New description:' + 2*CRLF + new_descr + CRLF
                     self.hdf.set_unescaped('email.changes_descr', cdescr)
                 elif field == 'cc':
                     (addcc, delcc) = self.diff_cc(old, new)
                     chgcc = ''
                     if delcc:
                         chgcc += wrap(" * cc: %s (removed)" % ', '.join(delcc), 
                                       self.COLS, ' ', ' ', CRLF)
                         chgcc += CRLF
                     if addcc:
                         chgcc += wrap(" * cc: %s (added)" % ', '.join(addcc), 
                                       self.COLS, ' ', ' ', CRLF)
                         chgcc += CRLF
                     if chgcc:
                         changes += chgcc
                     self.prev_cc += old and self.parse_cc(old) or []
                 else:
                     newv = new
                     l = 7 + len(field)
                     chg = wrap('%s => %s' % (old, new), self.COLS - l, '',
                                l * ' ', CRLF)
                     changes += '  * %s:  %s%s' % (field, chg, CRLF)
                 if newv:
                     self.hdf.set_unescaped('%s.oldvalue' % pfx, old)
                     self.hdf.set_unescaped('%s.newvalue' % pfx, newv)
         if changes:
             self.hdf.set_unescaped('email.changes_body', changes)
     self.ticket['link'] = link
     self.hdf.set_unescaped('ticket', self.ticket.values)
     NotifyEmail.notify(self, ticket.id, subject)
Example #39
0
    def _notify(self, ticket, newticket=True, modtime=None):
        self.ticket = ticket
        self.modtime = modtime
        self.newticket = newticket

        changes_body = ""
        self.reporter = ""
        self.owner = ""
        changes_descr = ""
        change_data = {}
        link = self.env.abs_href.ticket(ticket.id)
        summary = self.ticket["summary"]

        if not self.newticket and modtime:  # Ticket change
            from trac.ticket.web_ui import TicketModule

            for change in TicketModule(self.env).grouped_changelog_entries(ticket, self.db, when=modtime):
                if not change["permanent"]:  # attachment with same time...
                    continue
                change_data.update(
                    {
                        "author": obfuscate_email_address(change["author"]),
                        "comment": wrap(change["comment"], self.COLS, " ", " ", CRLF),
                    }
                )
                link += "#comment:%s" % str(change.get("cnum", ""))
                for field, values in change["fields"].iteritems():
                    old = values["old"]
                    new = values["new"]
                    newv = ""
                    if field == "description":
                        new_descr = wrap(new, self.COLS, " ", " ", CRLF)
                        old_descr = wrap(old, self.COLS, "> ", "> ", CRLF)
                        old_descr = old_descr.replace(2 * CRLF, CRLF + ">" + CRLF)
                        cdescr = CRLF
                        cdescr += "Old description:" + 2 * CRLF + old_descr + 2 * CRLF
                        cdescr += "New description:" + 2 * CRLF + new_descr + CRLF
                        changes_descr = cdescr
                    elif field == "summary":
                        summary = "%s (was: %s)" % (new, old)
                    elif field == "cc":
                        (addcc, delcc) = self.diff_cc(old, new)
                        chgcc = ""
                        if delcc:
                            chgcc += wrap(" * cc: %s (removed)" % ", ".join(delcc), self.COLS, " ", " ", CRLF) + CRLF
                        if addcc:
                            chgcc += wrap(" * cc: %s (added)" % ", ".join(addcc), self.COLS, " ", " ", CRLF) + CRLF
                        if chgcc:
                            changes_body += chgcc
                        self.prev_cc += old and self.parse_cc(old) or []
                    else:
                        if field in ["owner", "reporter"]:
                            old = obfuscate_email_address(old)
                            new = obfuscate_email_address(new)
                        newv = new
                        length = 7 + len(field)
                        spacer_old, spacer_new = " ", " "
                        if len(old + new) + length > self.COLS:
                            length = 5
                            if len(old) + length > self.COLS:
                                spacer_old = CRLF
                            if len(new) + length > self.COLS:
                                spacer_new = CRLF
                        chg = "* %s: %s%s%s=>%s%s" % (field, spacer_old, old, spacer_old, spacer_new, new)
                        chg = chg.replace(CRLF, CRLF + length * " ")
                        chg = wrap(chg, self.COLS, "", length * " ", CRLF)
                        changes_body += " %s%s" % (chg, CRLF)
                    if newv:
                        change_data[field] = {"oldvalue": old, "newvalue": new}

        ticket_values = ticket.values.copy()
        ticket_values["id"] = ticket.id
        ticket_values["description"] = wrap(
            ticket_values.get("description", ""), self.COLS, initial_indent=" ", subsequent_indent=" ", linesep=CRLF
        )
        ticket_values["new"] = self.newticket
        ticket_values["link"] = link

        subject = self.format_subj(summary)
        if not self.newticket:
            subject = "Re: " + subject
        self.data.update(
            {
                "ticket_props": self.format_props(),
                "ticket_body_hdr": self.format_hdr(),
                "subject": subject,
                "ticket": ticket_values,
                "changes_body": changes_body,
                "changes_descr": changes_descr,
                "change": change_data,
            }
        )
        NotifyEmail.notify(self, ticket.id, subject)
Example #40
0
 def notify(self, ticket, newticket=True, modtime=0):
     self.ticket = ticket
     self.modtime = modtime
     self.newticket = newticket
     self.ticket['description'] = wrap(self.ticket.values.get(
         'description', ''),
                                       self.COLS,
                                       initial_indent=' ',
                                       subsequent_indent=' ',
                                       linesep=CRLF)
     self.reporter = ''
     self.owner = ''
     self.hdf.set_unescaped('email.ticket_props', self.format_props())
     self.hdf.set_unescaped('email.ticket_body_hdr', self.format_hdr())
     self.hdf['ticket.new'] = self.newticket
     subject = self.format_subj()
     link = self.env.abs_href.ticket(ticket.id)
     if not self.newticket:
         subject = 'Re: ' + subject
     self.hdf.set_unescaped('email.subject', subject)
     changes = ''
     if not self.newticket and modtime:  # Ticket change
         from trac.ticket.web_ui import TicketModule
         for change in TicketModule(self.env).grouped_changelog_entries(
                 ticket, self.db, when=modtime):
             if not change['permanent']:  # attachment with same time...
                 continue
             self.hdf.set_unescaped('ticket.change.author',
                                    change['author'])
             self.hdf.set_unescaped(
                 'ticket.change.comment',
                 wrap(change['comment'], self.COLS, ' ', ' ', CRLF))
             link += '#comment:%s' % str(change.get('cnum', ''))
             for field, values in change['fields'].iteritems():
                 old = values['old']
                 new = values['new']
                 pfx = 'ticket.change.%s' % field
                 newv = ''
                 if field == 'description':
                     new_descr = wrap(new, self.COLS, ' ', ' ', CRLF)
                     old_descr = wrap(old, self.COLS, '> ', '> ', CRLF)
                     old_descr = old_descr.replace(2 * CRLF,
                                                   CRLF + '>' + CRLF)
                     cdescr = CRLF
                     cdescr += 'Old description:' + 2 * CRLF + old_descr + 2 * CRLF
                     cdescr += 'New description:' + 2 * CRLF + new_descr + CRLF
                     self.hdf.set_unescaped('email.changes_descr', cdescr)
                 elif field == 'cc':
                     (addcc, delcc) = self.diff_cc(old, new)
                     chgcc = ''
                     if delcc:
                         chgcc += wrap(
                             " * cc: %s (removed)" % ', '.join(delcc),
                             self.COLS, ' ', ' ', CRLF)
                         chgcc += CRLF
                     if addcc:
                         chgcc += wrap(
                             " * cc: %s (added)" % ', '.join(addcc),
                             self.COLS, ' ', ' ', CRLF)
                         chgcc += CRLF
                     if chgcc:
                         changes += chgcc
                     self.prev_cc += old and self.parse_cc(old) or []
                 else:
                     newv = new
                     l = 7 + len(field)
                     chg = wrap('%s => %s' % (old, new), self.COLS - l, '',
                                l * ' ', CRLF)
                     changes += '  * %s:  %s%s' % (field, chg, CRLF)
                 if newv:
                     self.hdf.set_unescaped('%s.oldvalue' % pfx, old)
                     self.hdf.set_unescaped('%s.newvalue' % pfx, newv)
         if changes:
             self.hdf.set_unescaped('email.changes_body', changes)
     self.ticket['link'] = link
     self.hdf.set_unescaped('ticket', self.ticket.values)
     NotifyEmail.notify(self, ticket.id, subject)
Example #41
0
    def notify(self, req, cursor, action, forum = None, topic = None,
      message = None, torcpts = [], ccrcpts = []):
        self.env.log.debug("action: %s" % action)
        self.env.log.debug("forum: %s" % forum)
        self.env.log.debug("topic: %s" % topic)
        self.env.log.debug("message: %s" % message)
        self.env.log.debug("torcpts: %s" % torcpts)
        self.env.log.debug("ccrcpts: %s" % ccrcpts)

        # Store link to currently notifying forum, topic and message.
        self.forum = forum
        self.topic = topic
        self.message = message
        self.torcpts = torcpts
        self.ccrcpts = ccrcpts

        # Get action and item of action.
        index = action.find('-')
        item = action[:index]
        action = action[index + 1:]

        # Which item notify about:
        if item == 'topic':
            # Prepare topic specific fields.
            re = ''
            title = 'Topic'
            id = self.topic['id']
            author = "    Author:  %s" % self.topic['author']
            time = "      Time:  %s" % format_datetime(self.topic['time'])
            body = self.topic['body']
            link = req.abs_href.discussion(self.forum['id'], self.topic['id'])

            # Save link for bad times.
            topic['link'] = link
        elif item == 'message':
            # Prepare message specific fields
            re = 'Re: '
            title = 'Message'
            id = self.message['id']
            author = "    Author:  %s" % self.message['author']
            time = "      Time:  %s" % format_datetime(self.message['time'])
            body = self.message['body']
            link = req.abs_href.discussion(self.forum['id'], self.topic['id'],
              self.message['id']) + '#%s' % self.message['id']

            # Save link for bad times.
            message['link'] = link
        else:
            return

        prefix = self.config.get('notification', 'smtp_subject_prefix')
        if prefix == '__default__':
            prefix = self.env.project_name
        moderators = "Moderators:  %s" % ' '.join(self.forum['moderators'])
        subject = self.topic['subject']

        # Set set e-mail template values.
        self.hdf.set_unescaped('discussion.re', re)
        self.hdf.set_unescaped('discussion.prefix', prefix)
        self.hdf.set_unescaped('discussion.title', title)
        self.hdf.set_unescaped('discussion.id', id)
        self.hdf.set_unescaped('discussion.author', author)
        self.hdf.set_unescaped('discussion.time', time)
        self.hdf.set_unescaped('discussion.moderators', moderators)
        self.hdf.set_unescaped('discussion.subject', subject)
        self.hdf.set_unescaped('discussion.body', body)
        self.hdf.set_unescaped('discussion.link', link)
        self.hdf.set_unescaped('discussion.project_name',
          self.env.project_name)
        self.hdf.set_unescaped('discussion.project_description',
          self.env.project_description)
        self.hdf.set_unescaped('discussion.project_url', self.env.project_url)

        # Render body and send notification.
        subject = to_unicode(self.hdf.render('discussion-notify-subject.cs'))
        NotifyEmail.notify(self, id, subject)
Example #42
0
    def notify(self,
               req,
               cursor,
               action,
               forum=None,
               topic=None,
               message=None,
               torcpts=[],
               ccrcpts=[]):
        self.env.log.debug("action: %s" % action)
        self.env.log.debug("forum: %s" % forum)
        self.env.log.debug("topic: %s" % topic)
        self.env.log.debug("message: %s" % message)
        self.env.log.debug("torcpts: %s" % torcpts)
        self.env.log.debug("ccrcpts: %s" % ccrcpts)

        # Store link to currently notifying forum, topic and message.
        self.forum = forum
        self.topic = topic
        self.message = message
        self.torcpts = torcpts
        self.ccrcpts = ccrcpts

        # Get action and item of action.
        index = action.find('-')
        item = action[:index]
        action = action[index + 1:]

        # Which item notify about:
        if item == 'topic':
            # Prepare topic specific fields.
            re = ''
            title = 'Topic'
            id = self.topic['id']
            author = "    Author:  %s" % self.topic['author']
            time = "      Time:  %s" % format_datetime(self.topic['time'])
            body = self.topic['body']
            link = req.abs_href.discussion(self.forum['id'], self.topic['id'])

            # Save link for bad times.
            topic['link'] = link
        elif item == 'message':
            # Prepare message specific fields
            re = 'Re: '
            title = 'Message'
            id = self.message['id']
            author = "    Author:  %s" % self.message['author']
            time = "      Time:  %s" % format_datetime(self.message['time'])
            body = self.message['body']
            link = req.abs_href.discussion(
                self.forum['id'], self.topic['id'],
                self.message['id']) + '#%s' % self.message['id']

            # Save link for bad times.
            message['link'] = link
        else:
            return

        prefix = self.config.get('notification', 'smtp_subject_prefix')
        if prefix == '__default__':
            prefix = self.env.project_name
        moderators = "Moderators:  %s" % ' '.join(self.forum['moderators'])
        subject = self.topic['subject']

        # Set set e-mail template values.
        self.hdf.set_unescaped('discussion.re', re)
        self.hdf.set_unescaped('discussion.prefix', prefix)
        self.hdf.set_unescaped('discussion.title', title)
        self.hdf.set_unescaped('discussion.id', id)
        self.hdf.set_unescaped('discussion.author', author)
        self.hdf.set_unescaped('discussion.time', time)
        self.hdf.set_unescaped('discussion.moderators', moderators)
        self.hdf.set_unescaped('discussion.subject', subject)
        self.hdf.set_unescaped('discussion.body', body)
        self.hdf.set_unescaped('discussion.link', link)
        self.hdf.set_unescaped('discussion.project_name',
                               self.env.project_name)
        self.hdf.set_unescaped('discussion.project_description',
                               self.env.project_description)
        self.hdf.set_unescaped('discussion.project_url', self.env.project_url)

        # Render body and send notification.
        subject = to_unicode(self.hdf.render('discussion-notify-subject.cs'))
        NotifyEmail.notify(self, id, subject)
Example #43
0
    def _notify(self, ticket, newticket=True, modtime=None):
        self.ticket = ticket
        self.modtime = modtime
        self.newticket = newticket

        changes_body = ''
        self.reporter = ''
        self.owner = ''
        changes_descr = ''
        change_data = {}
        link = self.env.abs_href.ticket(ticket.id)
        summary = self.ticket['summary']
        author = None

        if not self.newticket and modtime:  # Ticket change
            from trac.ticket.web_ui import TicketModule
            for change in TicketModule(self.env).grouped_changelog_entries(
                    ticket, when=modtime):
                if not change['permanent']:  # attachment with same time...
                    continue
                author = change['author']
                change_data.update({
                    'author':
                    self.obfuscate_email(author),
                    'comment':
                    wrap(change['comment'], self.COLS, ' ', ' ', '\n',
                         self.ambiwidth)
                })
                link += '#comment:%s' % str(change.get('cnum', ''))
                for field, values in change['fields'].iteritems():
                    old = values['old']
                    new = values['new']
                    newv = ''
                    if field == 'description':
                        new_descr = wrap(new, self.COLS, ' ', ' ', '\n',
                                         self.ambiwidth)
                        old_descr = wrap(old, self.COLS, '> ', '> ', '\n',
                                         self.ambiwidth)
                        old_descr = old_descr.replace(2 * '\n', '\n' + '>' + \
                                                      '\n')
                        cdescr = '\n'
                        cdescr += 'Old description:' + 2 * '\n' + old_descr + \
                                  2 * '\n'
                        cdescr += 'New description:' + 2 * '\n' + new_descr + \
                                  '\n'
                        changes_descr = cdescr
                    elif field == 'summary':
                        summary = "%s (was: %s)" % (new, old)
                    elif field == 'cc':
                        (addcc, delcc) = self.diff_cc(old, new)
                        chgcc = ''
                        if delcc:
                            chgcc += wrap(
                                " * cc: %s (removed)" % ', '.join(delcc),
                                self.COLS, ' ', ' ', '\n',
                                self.ambiwidth) + '\n'
                        if addcc:
                            chgcc += wrap(
                                " * cc: %s (added)" % ', '.join(addcc),
                                self.COLS, ' ', ' ', '\n',
                                self.ambiwidth) + '\n'
                        if chgcc:
                            changes_body += chgcc
                        self.prev_cc += self.parse_cc(old) if old else []
                    else:
                        if field in ['owner', 'reporter']:
                            old = self.obfuscate_email(old)
                            new = self.obfuscate_email(new)
                        newv = new
                        length = 7 + len(field)
                        spacer_old, spacer_new = ' ', ' '
                        if len(old + new) + length > self.COLS:
                            length = 5
                            if len(old) + length > self.COLS:
                                spacer_old = '\n'
                            if len(new) + length > self.COLS:
                                spacer_new = '\n'
                        chg = '* %s: %s%s%s=>%s%s' % (field, spacer_old, old,
                                                      spacer_old, spacer_new,
                                                      new)
                        chg = chg.replace('\n', '\n' + length * ' ')
                        chg = wrap(chg, self.COLS, '', length * ' ', '\n',
                                   self.ambiwidth)
                        changes_body += ' %s%s' % (chg, '\n')
                    if newv:
                        change_data[field] = {'oldvalue': old, 'newvalue': new}

        if newticket:
            author = ticket['reporter']

        ticket_values = ticket.values.copy()
        ticket_values['id'] = ticket.id
        ticket_values['description'] = wrap(ticket_values.get(
            'description', ''),
                                            self.COLS,
                                            initial_indent=' ',
                                            subsequent_indent=' ',
                                            linesep='\n',
                                            ambiwidth=self.ambiwidth)
        ticket_values['new'] = self.newticket
        ticket_values['link'] = link

        subject = self.format_subj(summary)
        if not self.newticket:
            subject = 'Re: ' + subject
        self.data.update({
            'ticket_props': self.format_props(),
            'ticket_body_hdr': self.format_hdr(),
            'subject': subject,
            'ticket': ticket_values,
            'changes_body': changes_body,
            'changes_descr': changes_descr,
            'change': change_data
        })
        NotifyEmail.notify(self, ticket.id, subject, author)
Example #44
0
    def _notify(self, ticket, newticket=True, modtime=None):
        self.ticket = ticket
        self.modtime = modtime
        self.newticket = newticket

        changes_body = ''
        self.reporter = ''
        self.owner = ''
        changes_descr = ''
        change_data = {}
        link = self.env.abs_href.ticket(ticket.id)
        summary = self.ticket['summary']
        
        if not self.newticket and modtime:  # Ticket change
            from trac.ticket.web_ui import TicketModule
            for change in TicketModule(self.env).grouped_changelog_entries(
                                                ticket, self.db, when=modtime):
                if not change['permanent']: # attachment with same time...
                    continue
                change_data.update({
                    'author': obfuscate_email_address(change['author']),
                    'comment': wrap(change['comment'], self.COLS, ' ', ' ',
                                    CRLF)
                    })
                link += '#comment:%s' % str(change.get('cnum', ''))
                for field, values in change['fields'].iteritems():
                    old = values['old']
                    new = values['new']
                    newv = ''
                    if field == 'description':
                        new_descr = wrap(new, self.COLS, ' ', ' ', CRLF)
                        old_descr = wrap(old, self.COLS, '> ', '> ', CRLF)
                        old_descr = old_descr.replace(2 * CRLF, CRLF + '>' + \
                                                      CRLF)
                        cdescr = CRLF
                        cdescr += 'Old description:' + 2 * CRLF + old_descr + \
                                  2 * CRLF
                        cdescr += 'New description:' + 2 * CRLF + new_descr + \
                                  CRLF
                        changes_descr = cdescr
                    elif field == 'summary':
                        summary = "%s (was: %s)" % (new, old)
                    elif field == 'cc':
                        (addcc, delcc) = self.diff_cc(old, new)
                        chgcc = ''
                        if delcc:
                            chgcc += wrap(" * cc: %s (removed)" %
                                          ', '.join(delcc), 
                                          self.COLS, ' ', ' ', CRLF) + CRLF
                        if addcc:
                            chgcc += wrap(" * cc: %s (added)" %
                                          ', '.join(addcc), 
                                          self.COLS, ' ', ' ', CRLF) + CRLF
                        if chgcc:
                            changes_body += chgcc
                        self.prev_cc += old and self.parse_cc(old) or []
                    else:
                        if field in ['owner', 'reporter']:
                            old = obfuscate_email_address(old)
                            new = obfuscate_email_address(new)
                        newv = new
                        length = 7 + len(field)
                        spacer_old, spacer_new = ' ', ' '
                        if len(old + new) + length > self.COLS:
                            length = 5
                            if len(old) + length > self.COLS:
                                spacer_old = CRLF
                            if len(new) + length > self.COLS:
                                spacer_new = CRLF
                        chg = '* %s: %s%s%s=>%s%s' % (field, spacer_old, old,
                                                      spacer_old, spacer_new,
                                                      new)
                        chg = chg.replace(CRLF, CRLF + length * ' ')
                        chg = wrap(chg, self.COLS, '', length * ' ', CRLF)
                        changes_body += ' %s%s' % (chg, CRLF)
                    if newv:
                        change_data[field] = {'oldvalue': old, 'newvalue': new}
        
        ticket_values = ticket.values.copy()
        ticket_values['id'] = ticket.id
        ticket_values['description'] = wrap(
            ticket_values.get('description', ''), self.COLS,
            initial_indent=' ', subsequent_indent=' ', linesep=CRLF)
        ticket_values['new'] = self.newticket
        ticket_values['link'] = link
        
        subject = self.format_subj(summary)
        if not self.newticket:
            subject = 'Re: ' + subject
        self.data.update({
            'ticket_props': self.format_props(),
            'ticket_body_hdr': self.format_hdr(),
            'subject': subject,
            'ticket': ticket_values,
            'changes_body': changes_body,
            'changes_descr': changes_descr,
            'change': change_data
            })
        NotifyEmail.notify(self, ticket.id, subject)
Example #45
0
    def notify(self):
        if not self.queueid or not self.build:
            return False

        NotifyEmail.notify(self, self.queueid, self.subject)
        return True
Example #46
0
 def _generic_notify(self, relation, deleted):
     self.data.update(dict(
         created=not deleted,
         relation=relation,
     ))
     NotifyEmail.notify(self, '', '', '')