Edgewall Software

Ticket #2247: trac-never-notify-self-2247.patch

File trac-never-notify-self-2247.patch, 2.1 KB (added by nielsen@…, 3 years ago)

Patch to suppress notifying self of changes one is making via web interface

  • trac/Notify.py

    old new  
    159159    modtime = 0 
    160160    from_email = 'trac+ticket@localhost' 
    161161    COLS = 75 
     162    current_user = None 
    162163 
    163     def __init__(self, env): 
     164    def __init__(self, env, username): 
    164165        NotifyEmail.__init__(self, env) 
    165166        self.prev_cc = [] 
     167        self.current_user = username 
    166168 
    167169    def notify(self, ticket, newticket=True, modtime=0): 
    168170        self.ticket = ticket 
     
    273275        notify_reporter = val.lower() in TRUE 
    274276        val = self.config.get('notification', 'always_notify_owner') 
    275277        notify_owner = val.lower() in TRUE 
     278        val = self.config.get('notification', 'never_notify_self') 
     279        skip_current = val.lower() in TRUE 
    276280 
    277281        recipients = self.prev_cc 
    278282        cursor = self.db.cursor() 
     
    303307        # now convert recipients into email addresses where necessary 
    304308        emails = [] 
    305309        for recipient in recipients: 
     310            # Don't notify the current user 
     311            if skip_current and self.current_user: 
     312                if recipient == self.current_user or recipient == self.email_map[self.current_user]: 
     313                   continue 
    306314            if recipient.find('@') >= 0: 
    307315                emails.append(recipient) 
    308316            elif self.email_map.has_key(recipient): 
  • trac/ticket/web_ui.py

    old new  
    143143 
    144144        # Notify 
    145145        try: 
    146             tn = TicketNotifyEmail(self.env) 
     146            tn = TicketNotifyEmail(self.env, req.authname) 
    147147            tn.notify(ticket, newticket=True) 
    148148        except Exception, e: 
    149149            self.log.exception("Failure sending notification on creation of " 
     
    351351        db.commit() 
    352352 
    353353        try: 
    354             tn = TicketNotifyEmail(self.env) 
     354            tn = TicketNotifyEmail(self.env, req.authname) 
    355355            tn.notify(ticket, newticket=False, modtime=now) 
    356356        except Exception, e: 
    357357            self.log.exception("Failure sending notification on change to "