How change CC field upon ticket creation?

46 views
Skip to first unread message

Aikido Guy

unread,
Dec 12, 2020, 8:55:12 AM12/12/20
to trac-hacks
I'm using Trac 1.4.2 and am trying to create  a little plugin that will set the CC to a value when the ticket is created (in order to send out ticket creation email notifications). I then remove the CC afterwards in order to stop the email notifications.

1. I am able to change the description field but not the CC field
2. Is there a better way than to use ITicketManipulator?
3. Should I be using "cc" rather than "CC" as per CarbonCopySubscriber event.target['cc']? I tried both ways and, if I recall correctly, both did not work
4. Should I be calling something like _ticket_change_subscribers to indicate the change I've made to the ticket's cc field? I was under the impression that everything would happen magically under the hood :)

trac.ini:
   [notification-subscriber]
   always_notify_cc = CarbonCopySubscriber 
   [[ticket]]
   default_cc = 

And my custom plugin looks like the following (extra stuff removed):

implements(ITicketManipulator)

def validat_ticket(self, req, ticket):
   if '/newticket' not in str(req):   # is there a "better" way to check this?
           ticket["CC"] = ""    # remove the CC if we are not creating a new ticket
           return []

    if ticket["status"] == "new":
          if ticket["CC"]==None or ticket["CC"]=="":
              ticket["description"] = "blah" # this works
              ticket["CC"] = "blah" # but this does NOT work

   return []

Any tips would be gratefully accepted!

Kindly,
Aikido Guy


Reply all
Reply to author
Forward
0 new messages