On Tue, Mar 1, 2011 at 10:23 AM, ElJefeWatson <[email protected]>wrote:
> We have a large pile of external users who contact our help desk who
> then enters the ticket in trac for them or resolves it (password
> change, desktop config problems, etc), so they are not users that go
> into trac and configure their preferences. They help desk will enter
> their email address as the reporter. We want to email the reporter if
> their problem is logged as a trac ticket for a software change. When
> it gets approved for work we want another email to the reporter, and
> when it gets closed we want another email sent to them. All the
> statuses in between we don't want to mail bomb the reporter.
>
> In the Announcer plugin is there way to send emails to the reporter
> based on the status? I've hacked some new code to do that, but was
> wondering whether it was possible without that and I missed
> something.
>
>
I've looked for a similar type of functionality with the AnnouncerPlugin,
and could not find it either. I ended up using a ticket_custom field named
"nomail" that is a checkbox labelled "Suppress Mail". Then I added the
attached diff to the 0.11 version of the announcerplugin.
I seem to remember locating a version of this patch in a ticket on trac
hacks, and adapted it for my occasional needs to limit the amount of mail
going out. It would certainly be nicer to have this based on a set of
statuses where notifications would be suppressed.
chris
--
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en.
Index: 0.11/announcerplugin/producers/ticket.py
===================================================================
--- 0.11/announcerplugin/producers/ticket.py (revision 9871)
+++ 0.11/announcerplugin/producers/ticket.py (working copy)
@@ -1,5 +1,7 @@
from trac.core import *
from trac.config import BoolOption
+from trac.db import Table, Column, Index
+from trac.db import DatabaseManager
from trac.ticket.api import ITicketChangeListener
from announcerplugin.api import AnnouncementSystem, AnnouncementEvent
@@ -52,13 +54,24 @@
def ticket_changed(self, ticket, comment, author, old_values):
if old_values.keys() == ['cc'] and not comment and \
self.ignore_cc_changes:
- return
- announcer = AnnouncementSystem(ticket.env)
- announcer.send(
- TicketChangeEvent("ticket", "changed", ticket,
- comment, author, old_values
- )
- )
+ self.env.log.info("Suppressing mail for ticket %s due to only cc changes happened " % ticket.id)
+ else:
+ # Look for nomail flag, and if present suppress mail entirely.
+ self.env.log.debug("Checking for nomail flag for ticket %s " % ticket.id)
+ db = self.env.get_db_cnx()
+ cursor = db.cursor()
+ cursor.execute("select ticket, name, value from ticket_custom where ticket = %s and name = 'nomail' and value = '1'",
+ (ticket.id,))
+ row = cursor.fetchone()
+ if row:
+ self.env.log.info("Suppressing mail for ticket %s due to nomail" % ticket.id)
+ else:
+ announcer = AnnouncementSystem(ticket.env)
+ announcer.send(
+ TicketChangeEvent("ticket", "changed", ticket,
+ comment, author, old_values
+ )
+ )
def ticket_deleted(self, ticket):
pass