Edgewall Software

Ticket #6613 (new enhancement)

Opened 11 months ago

Last modified 11 months ago

TracNotification for new tickets only

Reported by: me@… Owned by: eblot
Priority: normal Milestone: 0.13
Component: notification Version: 0.10.3
Severity: normal Keywords:
Cc:

Description

For a project I'm working on (Warzone 2100), I'm currently setting up a Trac environment here (with an incomplete SSL certificate as of yet).

In this project we want to be sent notices on the mailinglist when new tickets are created. So I set up TracNotification to send some mails to the mailing list. The problem is though that we only want these notices on ticket creation, not when they're updated or modified. Unfortunately TracNotification didn't do this natively, so I had to extend the TicketNotifyEmail? class somewhat.

The attached patch contains this extension/modification and adds a new configuration option to the [notification] section in trac.ini.

  • cc_on_newticket: Email address(es) to send notifications about newly created tickets to, addresses can only be seen when use_public_cc is enabled (Cc:).

NOTE: This patch should work with trunk as well, it's just that I wrote it for my 0.10.3 Trac installation.

--
Giel

Attachments

trac-notification-cc_on_newticket.patch (1.1 KB) - added by me@… 11 months ago.
adds a TracNotification option for CC on new tickets

Change History

Changed 11 months ago by me@…

adds a TracNotification option for CC on new tickets

Changed 11 months ago by eblot

  • milestone 0.10.5 deleted

New features won't be integrated to the maintenance branch 0.10

The TracNotification subsystem will be rewritten for 0.12.

Changed 11 months ago by anonymous

For the rewrite of TracNotification I assume you mean trac.ticket.api.ITicketChangeListener as mentioned in PluginDevelopment? ?

Something like that seems to be in progress @ track-hacks: AnnouncerPlugin.

Also initially I used a patch like this (which would add these mail addresses to the public Cc: list always, indepent from the user_public_cc setting. I personally think this option (i.e. independence of user_public_cc) is better, though this patch feels more like a hack to me (as it changes the interface/function prototypes):

  • notification.py

    old new  
    5555        """Email address(es) to always send notifications to, 
    5656           addresses can be see by all recipients (Cc:).""") 
    5757 
     58    smtp_cc_on_newticket = Option('notification', 'smtp_cc_on_newticket', '', 
     59        """Email address(es) to send notifications about newly 
     60           created tickets to, addresses can be seen by all 
     61           recipients (Cc:).""") 
     62 
    5863    smtp_always_bcc = Option('notification', 'smtp_always_bcc', '', 
    5964        """Email address(es) to always send notifications to, 
    6065           addresses do not appear publicly (Bcc:). (''since 0.10'').""") 
     
    155160    longaddr_re = re.compile(r"^\s*(.*)\s+<(" + addrfmt + ")>\s*$"); 
    156161    nodomaddr_re = re.compile(r"[\w\d_\.\-]+") 
    157162    addrsep_re = re.compile(r"[;\s,]+") 
     163    newticket = None 
    158164 
    159165    def __init__(self, env): 
    160166        Notify.__init__(self, env) 
     
    192198        else: 
    193199            raise TracError, 'Invalid email encoding setting: %s' % pref 
    194200 
    195     def notify(self, resid, subject): 
     201    def notify(self, resid, subject, newticket=False): 
    196202        self.subject = subject 
     203        self.newticket = newticket 
    197204 
    198205        if not self.config.getbool('notification', 'smtp_enabled'): 
    199206            return 
     
    325332        bccaddrs = bccparam and \ 
    326333                   build_addresses(bccparam.replace(',', ' ').split()) or [] 
    327334 
     335        if self.newticket: 
     336            naccparam = self.config.get('notification', 'smtp_cc_on_newticket') 
     337            accaddrs += naccparam and \ 
     338                        build_addresses(naccparam.replace(',', ' ').split()) or [] 
     339 
    328340        recipients = [] 
    329341        (toaddrs, recipients) = remove_dup(toaddrs, recipients) 
    330342        (ccaddrs, recipients) = remove_dup(ccaddrs, recipients) 
  • ticket/notification.py

    old new  
    126126                self.hdf.set_unescaped('email.changes_body', changes) 
    127127        self.ticket['link'] = link 
    128128        self.hdf.set_unescaped('ticket', self.ticket.values) 
    129         NotifyEmail.notify(self, ticket.id, subject) 
     129        NotifyEmail.notify(self, ticket.id, subject, self.newticket) 
    130130 
    131131    def format_props(self): 
    132132        tkt = self.ticket 

Changed 11 months ago by cboos

  • milestone set to 0.12

See also Stephen Hansen's mail on trac-dev, Notification Architecture.

Setting the milestone tentatively to 0.12, as I think the new notification architecture should be able to allow for such requests, though not necessarily through the way proposed in the patch, rather using some more general ways, like in Stephen's proposal.

Add/Change #6613 (TracNotification for new tickets only)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from eblot. Next status will be 'new'
The owner will change from eblot to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.