简体   繁体   中英

Email notification upon ticket modification in Fossil

I need to receive an email notification whenever a user creates a ticket or a ticket gets updated. Fossil has something called ticket hook, which is accessible in the UI from admin -> transfers -> Ticket . I have tried the following code from here :

set project simpletask
tclInvoke package require http
query {SELECT title, status
        FROM ticket
        WHERE tkt_uuid=$uuid} {
   set title [tclInvoke http::formatQuery  $title]
   http -asynchronous -- http://127.0.0.1/cgi-bin/tkt-hook?uuid=$uuid&title=$title&status=$status&project=$project
}

I expect this code to be executed once a ticket is modified, but I don't really know how to modify it to send an email, and how I can specify to whom the email should be sent to.

Does anyone have a sample TH1 code for sending email notifications that can share?

TH1 is not able to do this on its own; it's too limited (and deliberately so). If you've got invocation of Tcl enabled in TH1 (it's not enabled by default) then you can use something like:

### THIS IS TH1 ###
tclInvoke source /some/dir/scripts/emailsender.tcl
query {SELECT title, status
       FROM ticket
       WHERE tkt_uuid=$uuid} {
    tclInvoke send_email $title $status $uuid
}

Then you just need to make sure that your emailsender.tcl script (in the above location) defines a procedure send_email that does what you want. You're talking about something like this:

### THIS IS TCL ###
package require mime
package require smtp

# Where to route messages through; IMPORTANT!
variable smtp_host smtp.example.com

proc send_email {title status uuid} {
    variable smtp_host
    set t [mime::initialize -canonical text/plain \
            -string "state is now $status for $uuid"]
    mime::setheader $t Subject "Change to '$title'"
    smtp::sendmessage $t -recipients you@example.com -servers $smtp_host
    mime::finalize $t
}

You'll need to pass across more fields, insert more logic to generate a message, choose who to send the message to (a mailing list is a good start!) and so on, but that's the core of it all. You may also need to explicitly lappend the directory containing the Tcllib packages to the global auto_path ; that script is going to be very specific to your configuration.


Or you could make a script that listens to that port you push a notification to using the sample script and work with that. That would be easier to abuse though; not recommended.

I just followed IFTTT approach, where we used IFTTT service to connect rss feed of Fossil scm to Gmail channel. It worked.

Please refer: http://lists.fossil-scm.org:8080/pipermail/fossil-users/2013-August/013330.html https://ifttt.com/recipes/109526

https://ifttt.com/recipes/109526 --> is for email notification for New ticket, that can be modified (change keyword or simple phrase) to send email for any ticket modification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM