Edgewall Software

Opened 16 years ago

Closed 7 years ago

Last modified 7 years ago

#6516 closed enhancement (wontfix)

[PATCH] Including content of ticket fields in outgoing notification email headers

Reported by: qwp0 Owned by:
Priority: normal Milestone:
Component: notification Version:
Severity: normal Keywords: ghop consider review patch
Cc: doug.hellmann@…, androsis@…, Thijs Triemstra Branch:
Release Notes:
API Changes:
Internal Changes:


I (as 'androsis') have claimed a ticket in GHOP ( http://code.google.com/p/google-highly-open-participation-psf/issues/detail?id=255 ) — "Update trac to include more ticket fields in outgoing email headers". There have been already posted some patchs, so it maybe useful for you to have a ticket here too.

I attach my most recent patch for this task (it can be found on the GHOP ticket of this issue too)…

P.S.: I have not found any existing ticket where I could post this, so if there is already a ticket about that I'm very sorry.

Attachments (2)

trac-notification-headers_v3(tests).diff (2.3 KB ) - added by qwp0 16 years ago.
trac-notification-x_trac_ticket_headers.diff (6.8 KB ) - added by Christian Boos 15 years ago.
copy of qwp0's patch linked in comment:9

Download all attachments as: .zip

Change History (21)

comment:1 by anonymous, 16 years ago

Cc: doug.hellmann@… added

comment:2 by anonymous, 16 years ago

Summary: Including content of ticket fields in outgoing notification email headers[PATCH] Including content of ticket fields in outgoing notification email headers

comment:3 by sid, 16 years ago

Type: defectenhancement

comment:4 by Emmanuel Blot, 16 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #1359

comment:5 by doug.hellmann, 16 years ago

Resolution: duplicate
Status: closedreopened

#1359 is not the same as this ticket.

In #1359, only changed fields are included in the header. In this ticket, all fields are always included in the headers.

The two patches could be merged or otherwise made compatible, but they don't provide the same functionality.

comment:6 by Christian Boos, 16 years ago

Keywords: consider added
Milestone: 0.12

comment:7 by androsis@…, 16 years ago

Cc: androsis@… added

comment:8 by Christian Boos, 16 years ago

Closed #1359 as duplicate of this one.

We could eventually have something like a smtp_x_trac_ticket_headers option with the possible values of ALL, CHANGED or a list of fields.

comment:9 by qwp0, 16 years ago

Hi, I created a patch which works with the configuration option mentioned by Christian, created against the trunk repository, exactly r7639. I don't know if it's ideal because this ticket should be done for milestone:0.13.

Unfortunaly, because of the too extensive unit testing I can't upload it here, sorry — the file is available at http://tests.php5.sk/tmp/trac-notification-x_trac_ticket_headers.diff

I know it's none of my business now for the GHOP task (see the ticket description) is not actual but I hope the patch will be useful.

by Christian Boos, 15 years ago

copy of qwp0's patch linked in comment:9

comment:10 by Thijs Triemstra, 13 years ago

Cc: Thijs Triemstra added
Keywords: review added

Patch needs a review.

comment:11 by Thijs Triemstra, 13 years ago

Keywords: patch added

comment:12 by jasa.david@…, 12 years ago

Hi, is there any chance of getting this patch merged soon, to be able to make its way to 0.13?

comment:13 by phooper0001@…, 11 years ago

Can you restrict the number of header fields that are included on the annnouncer email, based on the ticket type ?

in reply to:  13 comment:14 by Christian Boos, 11 years ago

Replying to phooper0001@…:

Can you restrict the number of header fields that are included on the annnouncer email, based on the ticket type ?

From the patch:

"Possible values: ALL, CHANGED or comma-separated list of ticket properties"

But not depending on the ticket type. That should be relatively trivial to add (e.g. another config options whose name includes the ticket type).

Back to the original patch: it looks fine and useful, comes with tests et al… Only lacks a "champion". I've been away from the notification code for too long and we just don't dare to touch it much these days given all the existing known issues and the recurring plans for replacement. But still, if someone would like to have a try at reviving the patch, he would be welcome.

comment:15 by ethan.jucovy@…, 11 years ago

I don't quite see the need for the proposed smtp_x_trac_ticket_headers option.

Unless this option is set to the value "CHANGED", it doesn't seem like it would address the use case in #1359 — setting up a mail filter for tickets whose owner was just changed to myself. If the option is set to "CHANGED" then this use case will be supported, but it means that there needs to be cooperation between the end-user's mail filters and the trac administrators who are configuring the system. And if I'm participating in several Trac environments, I can't confidently set up the same mail filters for all of the environments.

Meanwhile, I don't really see the advantage of having the option. Why would an administrator choose to suppress any headers?

It seems like this is better off being non-configurable: always send a separate mail header for the current value of every field, and a separate value for the old value of every field. That way setting up mail filters to detect changes, or current values whether or not they've changed, would be easy and consistent.

comment:16 by Ryan J Ollos, 9 years ago

Owner: Emmanuel Blot removed
Status: reopenednew

comment:17 by Peter Suter, 7 years ago

Could now be implemented as a plugin? Untested:

from trac.config import ListOption
from trac.core import Component, implements
from trac.notification.api import IEmailDecorator
from trac.notification.mail import set_header

class TicketFieldEmailDecorator(Component):


    smtp_x_trac_ticket_headers = ListOption('notification',
            'smtp_x_trac_ticket_headers', 'CHANGED',
            doc="""Possible values: ''ALL'', ''CHANGED'' or comma-separated
            list of ticket properties.

            Those properties are put into the e-mail headers when notifying
            about ticket updates.""")

    # IEmailDecorator methods
    def decorate_message(self, event, message, charset):
        if event.realm != 'ticket' or event.category == 'batchmodify':
        def header(value, *parts):
            name = '-'.join(part.capitalize() for part in parts)
            set_header(message, name, value, charset)
        fields = list(self.smtp_x_trac_ticket_headers)
        prefix = 'X-Trac-Ticket'
        if fields == ['CHANGED']:
            for item, change in event.changes['fields'].iteritems():
                for type, value in change.iteritems():
                    header(value, prefix, item, type)
        elif fields == ['ALL']:
            for item in event.target.values:
                header(event.target.values[item], prefix, item)
            for item in fields:
                header(event.target.values[item], prefix, item)

comment:18 by Peter Suter, 7 years ago

Milestone: next-major-releases
Resolution: wontfix
Status: newclosed

comment:19 by Ryan J Ollos, 7 years ago

I tested the recipe and confirm that it works as described.

X-trac-ticket-Milestone: milestone4

Modify Ticket

Change Properties
Set your email in Preferences
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.