Edgewall Software
Modify

Opened 11 years ago

Last modified 18 months ago

#7793 new enhancement

[PATCH] Mail notifications for a ticket with multiple owners / reporters

Reported by: jsch@… Owned by:
Priority: normal Milestone: next-major-releases
Component: notification Version: 0.12dev
Severity: normal Keywords: patch
Cc: Branch:
Release Notes:
API Changes:

Description (last modified by Christian Boos)

When a new ticket is created in a component with multiple owners (i.e., the component owner field contains "user1,user2"), currently no owner gets a notification, because this field is not parsed and thus no corresponding e-mail address can be determined.

I find it useful to have a component have multiple owners that are each equally responsible or interested in new tickets.

A small diff to trac/ticket/notification.py which fixes the issue for me is included.

Note

Trac doesn't currently support multiple owners, therefore this feature depends on #2662.

Attachments (1)

trac-ticket-notify-multiowner-component.diff (561 bytes ) - added by jsch@… 11 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 by anonymous, 11 years ago

Version: none0.12dev

comment:2 by anonymous, 11 years ago

Summary: Mail notifications for a new ticket for multiple owners of the component[PATCH] Mail notifications for a new ticket for multiple owners of the component

comment:3 by ebray, 11 years ago

I'm not so sure about this, as it's basically implementing a naïve approach to "multiple owners" which still doesn't really exist in Trac. See #2662. One problem with this, while uncommon, is that splitting usernames by commas won't work in situations where LDAP DNs are being used as usernames.

Also, that replace(',', ' ') is unnecessary—better to do something like [u.strip() for u in row[2].split(',')]. But that's a moot point.

Last edited 9 years ago by Christian Boos (previous) (diff)

in reply to:  3 comment:4 by jsch@…, 11 years ago

Replying to ebray:

I'm not so sure about this, as it's basically implementing a na&imacron;ve approach to "multiple owners" which still doesn't really exist in Trac. See #2662. One problem with this, while uncommon, is that splitting usernames by commas won't work in situations where LDAP DNs are being used as usernames.

Then I guess I don't want to patch the ticket system but add some "default CC for new tickets" to my components. Sounds like it would fit the current system better but also sounds like quite some extra effort to me. Any thoughts?

comment:5 by Christian Boos, 11 years ago

Component: ticket systemnotification
Milestone: 0.13
Owner: set to Emmanuel Blot

comment:6 by bobbysmith007@…, 10 years ago

Summary: [PATCH] Mail notifications for a new ticket for multiple owners of the component[PATCH] Mail notifications for a ticket with multiple owners / reporters

I just wanted to add my 2c that I think that something like below should be implemented.

It is non-intuitive that users can add comma separated names to the cc field, but the identical (from the user perspective) owner and reporter fields fail to notify with multiple user names. I have this patched into my trac and it seems to be working appropriately (though without full LDAP usernames).

  def preplist (lst):
    return lst and lst.replace(',',' ').split() or []
  if row:
      ccrecipients += preplist(row[0])
      self.reporter = row[1]
      self.owner = row[2]
      if notify_reporter:
        torecipients += preplist(row[1])
      if notify_owner:
        torecipients += preplist(row[2])

I also generalized the summary to reflect that I think that this is a more general problem that affects both report and owner.

comment:7 by Remy Blank, 10 years ago

#8580 was closed as a duplicate, and contains a simple solution proposal.

comment:8 by suzzee, 9 years ago

Is there a big difference between Trac versions? I'm using Trac-0.11.6rc1-py2.5.egg / Trac-0.12rc1-py2.5.egg*. The notification.py for 0.11.6rc1 isn't the same as listed in http://trac.edgewall.org/browser/tags/trac-0.11.5/trac/ticket/notification.py#L253. Instead the function looks like this:

    def get_recipients(self, resid):
        """Return a pair of list of subscribers to the resource 'resid'.
        
        First list represents the direct recipients (To:), second list
        represents the recipients in carbon copy (Cc:).
        """
        raise NotImplementedError

Any help would be appreciated. Thank you.

(* I'm actually using Trac-0.12rc1-py2.5.egg, but it isn't a folder?)

Last edited 18 months ago by Jun Omae (previous) (diff)

comment:9 by anonymous, 9 years ago

Hello all,

I am new using trac, and I am starting using trac project 11.5 and Announcerplugin.I have a problem with owners field where my trac project isn't able to send mail notifications to multiple owners for the same ticket when a change has been produced.

I've changed line 254 from my notification.py file according to this ticket but it doesn't sort out the problem. Do I have to change any other file else into the announcerplugin too?, or Do I have to reinstall the plugin once I've changed this file?, Maybe reinstall the whole trac project?

Thank you very much in advance,

Best regards,

Eddie

comment:10 by anonymous, 9 years ago

Hello all again,

I attach you part of my trac.log file in order to clarify something else about this problem

2011-01-13 10:36:22,414 Trac[api] DEBUG: AnnouncementSystem found the following subscribers capable of handling 'ticket, changed': StaticTicketSubscriber, LegacyTicketSubscriber, CarbonCopySubscriber, WatchSubscriber
2011-01-13 10:36:22,414 Trac[ticket_compat] DEBUG: StaticTicketSubscriber added 'user1@gmail.com' because of rule: smtp_always_cc
2011-01-13 10:36:22,414 Trac[ticket_compat] DEBUG: LegacyTicketSubscriber added 'user1, user2 (authenticated)' because of rule: always_notify_owner
2011-01-13 10:36:22,415 Trac[ticket_compat] DEBUG: LegacyTicketSubscriber added 'user1 (authenticated)' because of rule: always_notify_reporter
2011-01-13 10:36:22,415 Trac[ticket_compat] DEBUG: LegacyTicketSubscriber added 'user1 (authenticated)' because of rule: always_notify_updater
2011-01-13 10:36:22,415 Trac[ticket_compat] DEBUG: CarbonCopySubscriber added 'user1 <None>' because of rule: carbon copied
2011-01-13 10:36:22,416 Trac[api] DEBUG: AnnouncementSystem has found the following subscriptions: [user1(authenticated) via email], [user1, user2(authenticated) via email], [user1@gmail.com(not authenticated) via email]
2011-01-13 10:36:22,416 Trac[email_distributor] DEBUG: EmailDistributor has found the following formats capable of handling 'email' of 'ticket': text/html, text/plain
2011-01-13 10:36:22,417 Trac[email_distributor] DEBUG: EmailDistributor was unable to find an address for: user1, user2 (authenticated)

As you can see the problem is the chain of multiple owners is not splitted in several users as it should be work, otherwise in CC field it works fine.

Does somebody knows what is exactly the difference between StaticTicketSubscriber and LegacySubscriber because according to the file trac.log is the only main diff I can see.

Thank you very much again,

Best regards,

Eddie

Last edited 18 months ago by Jun Omae (previous) (diff)

comment:11 by Remy Blank, 9 years ago

Please use the MailingList and / or IrcChannel for support questions. Thank you.

comment:12 by Christian Boos, 9 years ago

Description: modified (diff)

Integrated remark from comment:3 as a note in the description.

comment:13 by Ryan J Ollos, 5 years ago

Owner: Emmanuel Blot removed

comment:14 by figaro, 4 years ago

Keywords: patch added

comment:15 by anonymous, 18 months ago

from trac.core import Component, implements
from trac.notification.api import INotificationSubscriber, NotificationSystem
from trac.ticket.notification import _is_ticket_change_event
from trac.util.translation import _
from trac.web.chrome import Chrome


class TicketMultiOwnerSubscriber(Component):
    """Allows ticket owners to subscribe to their tickets.
    Replaces TicketOwnerSubscriber.
    Allows multiple reporters per ticket like CarbonCopySubscriber.
    """

    implements(INotificationSubscriber)

    def matches(self, event):
        owners = None
        if _is_ticket_change_event(event):
            # Owners field is stored as comma-separated string. Parse to set.
            chrome = Chrome(self.env)
            to_set = lambda cc: set(chrome.cc_list(cc))
            owners = to_set(event.target['owner'] or '')

            # Harvest previous owner
            if 'fields' in event.changes and 'owner' in event.changes['fields']:
                owners.update(to_set(event.changes['fields']['owner']['old']))
        return _ticket_change_subscribers(self, owners)

    def description(self):
        return _("Ticket that I own is created or modified")

    def default_subscriptions(self):
        klass = self.__class__.__name__
        return NotificationSystem(self.env).default_subscriptions(klass)

    def requires_authentication(self):
        return True


class TicketMultiReporterSubscriber(Component):
    """Allows the users to subscribe to tickets that they report.
    Replaces TicketReporterSubscriber.
    Allows multiple reporters per ticket like CarbonCopySubscriber.
    """

    implements(INotificationSubscriber)

    def matches(self, event):
        reporters = None
        if _is_ticket_change_event(event):
            # Reporter field is stored as comma-separated string. Parse to set.
            chrome = Chrome(self.env)
            to_set = lambda cc: set(chrome.cc_list(cc))
            reporters = to_set(event.target['reporter'] or '')

            # Harvest previous Reporter field
            if 'fields' in event.changes and 'reporter' in event.changes['fields']:
                reporters.update(to_set(event.changes['fields']['reporter']['old']))
        return _ticket_change_subscribers(self, reporters)

    def description(self):
        return _("Ticket that I reported is modified")

    def default_subscriptions(self):
        klass = self.__class__.__name__
        return NotificationSystem(self.env).default_subscriptions(klass)

    def requires_authentication(self):
        return True

Should work like the others on wiki:CookBook/Notification/Subscriptions, except that the normal components TicketOwnerSubscriber and TicketReporterSubscriber must be disabled.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned. Next status will be 'new'.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


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