#6613 closed enhancement (fixed)
TracNotification for new tickets only
Reported by: | Owned by: | Ryan J Ollos | |
---|---|---|---|
Priority: | normal | Milestone: | 1.2.3 |
Component: | notification | Version: | 0.10.3 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Added a notification subscriber for new tickets. |
||
API Changes: | |||
Internal Changes: |
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 (1)
Change History (13)
by , 17 years ago
Attachment: | trac-notification-cc_on_newticket.patch added |
---|
comment:1 by , 17 years ago
Milestone: | 0.10.5 |
---|
New features won't be integrated to the maintenance branch 0.10
The TracNotification subsystem will be rewritten for 0.12.
comment:2 by , 17 years ago
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 55 55 """Email address(es) to always send notifications to, 56 56 addresses can be see by all recipients (Cc:).""") 57 57 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 58 63 smtp_always_bcc = Option('notification', 'smtp_always_bcc', '', 59 64 """Email address(es) to always send notifications to, 60 65 addresses do not appear publicly (Bcc:). (''since 0.10'').""") … … 155 160 longaddr_re = re.compile(r"^\s*(.*)\s+<(" + addrfmt + ")>\s*$"); 156 161 nodomaddr_re = re.compile(r"[\w\d_\.\-]+") 157 162 addrsep_re = re.compile(r"[;\s,]+") 163 newticket = None 158 164 159 165 def __init__(self, env): 160 166 Notify.__init__(self, env) … … 192 198 else: 193 199 raise TracError, 'Invalid email encoding setting: %s' % pref 194 200 195 def notify(self, resid, subject ):201 def notify(self, resid, subject, newticket=False): 196 202 self.subject = subject 203 self.newticket = newticket 197 204 198 205 if not self.config.getbool('notification', 'smtp_enabled'): 199 206 return … … 325 332 bccaddrs = bccparam and \ 326 333 build_addresses(bccparam.replace(',', ' ').split()) or [] 327 334 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 328 340 recipients = [] 329 341 (toaddrs, recipients) = remove_dup(toaddrs, recipients) 330 342 (ccaddrs, recipients) = remove_dup(ccaddrs, recipients) -
ticket/notification.py
old new 126 126 self.hdf.set_unescaped('email.changes_body', changes) 127 127 self.ticket['link'] = link 128 128 self.hdf.set_unescaped('ticket', self.ticket.values) 129 NotifyEmail.notify(self, ticket.id, subject )129 NotifyEmail.notify(self, ticket.id, subject, self.newticket) 130 130 131 131 def format_props(self): 132 132 tkt = self.ticket
comment:3 by , 17 years ago
Milestone: | → 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.
comment:4 by , 10 years ago
Might still be useful 7 years later with many Trac releases in between. Has it made its way into the product?
comment:5 by , 10 years ago
Owner: | removed |
---|
comment:6 by , 8 years ago
Could now be implemented as a plugin (or optional component)? Untested:
from trac.core import Component, implements from trac.notification.api import INotificationSubscriber from trac.notification.model import Subscription class NewTicketSubscriber(Component): """Subscribe to new created tickets.""" implements(INotificationSubscriber) # INotificationSubscriber methods def matches(self, event): if event.realm != 'ticket': return if event.category != 'created': return klass = self.__class__.__name__ for s in Subscription.find_by_class(self.env, klass): yield s.subscription_tuple() def description(self): return _("Any ticket is created") def default_subscriptions(self): return [] def requires_authentication(self): return False
comment:7 by , 8 years ago
See wiki:CookBook/Notification/Subscriptions#Subscribetonewcreatedtickets
Maybe a candidate for tracopt
?
comment:9 by , 8 years ago
Or maybe just add to trac.ticket.notification
. I don't see any downsides to enabling NewTicketSubscriber
in a default installation.
comment:10 by , 7 years ago
Milestone: | next-major-releases → 1.2.3 |
---|---|
Owner: | set to |
Release Notes: | modified (diff) |
Status: | new → assigned |
Proposed changes in [99a7c844f/rjollos.git].
comment:11 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:12 by , 6 years ago
Release Notes: | modified (diff) |
---|
adds a TracNotification option for CC on new tickets