Edgewall Software
Modify

Opened 18 years ago

Closed 10 years ago

Last modified 8 years ago

#3517 closed enhancement (fixed)

Notification plugin

Reported by: wichert@… Owned by: Peter Suter
Priority: normal Milestone: 1.1.3
Component: notification Version: 0.9.6
Severity: major Keywords:
Cc: ufs@…, davidf@…, pacopablo@…, Jun Omae Branch:
Release Notes:

Allow plugins to extend notification system.

API Changes:

Added new API for notification distribution and extension points:

Internal Changes:

Description

Currently trac only supports email notifications. For some environments it it would be very practical to use different kinds of notifications; for example to send a SMS when tickets of a specific type are files, or to notify CIA of new tickets.

It seems sensible to create an extension point for the notification infrastructure so one or more plugins can handle notifications.

Attachments (3)

trac-cia.diff (2.2 KB ) - added by wichert@… 18 years ago.
Example of submitting messages to CIA from trac
trac-0.10-cia.diff (4.6 KB ) - added by wichert@… 17 years ago.
CIA for trac 0.10.4
trac-0.10.4-cia.diff (5.6 KB ) - added by wichert@… 17 years ago.
CIA for trac 0.10.4

Download all attachments as: .zip

Change History (29)

by wichert@…, 18 years ago

Attachment: trac-cia.diff added

Example of submitting messages to CIA from trac

comment:1 by wichert@…, 18 years ago

I've added a patch which implements a trac-CIA connection. This implementation is quite bad since it hooks trac directly into the email notifier logic, but the xmlrpc code can easily be reused.

comment:2 by Christian Boos, 18 years ago

Component: ticket systemnotification
Milestone: 0.12
Owner: changed from Jonas Borgström to Emmanuel Blot
Severity: normalmajor

Yes, a more generic infrastructure for notifications will be a big topic for 0.12.

comment:3 by Pedro Algarvio, aka, s0undt3ch <ufs@…>, 17 years ago

Cc: ufs@… added

comment:4 by pookey@…, 17 years ago

I'd really appreciate if someone could manage to update this patch to work with 0.10.4 - my python skills are sadly lacking!

comment:5 by wichert@…, 17 years ago

I did an improved version of that patch for 0.10 a while ago. I'll add it to this issue.

by wichert@…, 17 years ago

Attachment: trac-0.10-cia.diff added

CIA for trac 0.10.4

by wichert@…, 17 years ago

Attachment: trac-0.10.4-cia.diff added

CIA for trac 0.10.4

comment:6 by davidf@…, 17 years ago

Cc: davidf@… added

Also wanting to add a generic jabber notification system…. again this would make sense as a plugin

comment:7 by anonymous, 16 years ago

We definitely need a few explanations about how to make it work. I've patched my trac, figured a few config items from code, but i can't make it work. Can someone please post instructions and a config sample? Thanks in advance.

in reply to:  6 comment:8 by Emmanuel Blot, 16 years ago

Replying to davidf@sjsoft.com:

Also wanting to add a generic jabber notification system…. again this would make sense as a plugin

BTW, for Mac users only: I've written a growl notification plugin.

comment:9 by wichert@…, 16 years ago

For reference this is the configuration we use for Plone:

[notification]
always_notify_owner = true
always_notify_reporter = true
cia_enabled = true
cia_project = Plone
cia_server = http://cia.navi.cx
smtp_always_cc = plone-collector@objectrealms.net
smtp_enabled = true
smtp_from = discard@antiloop.plone.org
smtp_password = 
smtp_port = 25
smtp_replyto = discard@antiloop.plone.org
smtp_server = localhost
smtp_user = 

comment:10 by John Hampton, 16 years ago

Cc: pacopablo@… added

comment:11 by Peter Suter, 11 years ago

The INotificationDistributor extension point of the AdvancedNotification proposal provides a clean way for plugins to implement such alternative notification protocols.

The proposed changes can be found in log:psuter@advanced-notification-mail-distribution.

Several other new extension points and public APIs for plugins are also introduced there. These might have to be reviewed and discussed in some more detail. For example I listed some open questions in the relevant wiki pages (e.g. NotificationEvent API, INotificationFormatter and IEmailAddressResolver).

comment:12 by Peter Suter, 11 years ago

Milestone: next-major-releases1.1.2
Owner: changed from Emmanuel Blot to Peter Suter
Status: newassigned

comment:13 by Jun Omae, 11 years ago

Cc: Jun Omae added

comment:14 by Ryan J Ollos, 11 years ago

Milestone: 1.1.21.1.3

in reply to:  11 comment:15 by Peter Suter, 10 years ago

The proposed changes can be found in log:psuter@advanced-notification-mail-distribution.

Updated in log:psuter@advanced-notification-mail-distribution.2.

These might have to be reviewed and discussed in some more detail. For example I listed some open questions in the relevant wiki pages (e.g. NotificationEvent API, INotificationFormatter and IEmailAddressResolver).

I'll probably just commit the current state. We can still fine-tune later if problems emerge.

comment:16 by Peter Suter, 10 years ago

API Changes: modified (diff)
Release Notes: modified (diff)

Committed to trunk in [13454]. I'll follow up with changes for milestone delete and retargeting events:

  • trac/ticket/roadmap.py

    diff -r c5cadf7e6beb trac/ticket/roadmap.py
    a b  
    3535from trac.util.text import CRLF, exception_to_unicode, to_unicode
    3636from trac.util.translation import _, tag_
    3737from trac.ticket.api import TicketSystem
    38 from trac.ticket.notification import BatchTicketNotifyEmail
     38from trac.ticket.notification import send_ticket_event, BatchTicketChangeEvent
    3939from trac.ticket.model import Milestone, MilestoneCache, Ticket, \
    4040                              group_milestones
    4141from trac.timeline.api import ITimelineEventProvider
     
    775775                new_values = {'milestone': retarget_to}
    776776                comment = comment or \
    777777                          _("Open tickets retargeted after milestone closed")
    778                 tn = BatchTicketNotifyEmail(self.env)
     778                event = BatchTicketChangeEvent(retargeted_tickets, None,
     779                                               req.authname, comment,
     780                                               new_values, None)
    779781                try:
    780                     tn.notify(retargeted_tickets, new_values, comment, None,
    781                               req.authname)
     782                    send_ticket_event(self.env, self.config, event)
    782783                except Exception as e:
    783784                    self.log.error("Failure sending notification on ticket "
    784785                                   "batch change: %s",
     
    827828                              retarget=retarget_to))
    828829            new_values = {'milestone': retarget_to}
    829830            comment = _("Tickets retargeted after milestone deleted")
    830             tn = BatchTicketNotifyEmail(self.env)
     831            event = BatchTicketChangeEvent(retargeted_tickets, None,
     832                                           req.authname, comment, new_values,
     833                                           None)
    831834            try:
    832                 tn.notify(retargeted_tickets, new_values, comment, None,
    833                           req.authname)
     835                send_ticket_event(self.env, self.config, event)
    834836            except Exception as e:
    835837                self.log.error("Failure sending notification on ticket batch "
    836838                               "change: %s", exception_to_unicode(e))

in reply to:  17 comment:18 by Ryan J Ollos, 10 years ago

Replying to psuter:

(Replacing an large table and list of plugins etc. Should that information be kept somewhere?)

I would just add a link somewhere on the page stating that the pre-1.1.3 Trac Notification API is documented at TracDev/NotificationApi@3.

Last edited 10 years ago by Ryan J Ollos (previous) (diff)

in reply to:  16 comment:19 by Peter Suter, 10 years ago

Resolution: fixed
Status: assignedclosed

I'll follow up with changes for milestone delete and retargeting events:

Committed in [13458].

Replying to rjollos:

I would just add a link somewhere on the page stating that the pre-1.1.3 Trac Notification API is documented at TracDev/NotificationApi@3.

Thanks, done.

comment:20 by Ryan J Ollos, 9 years ago

TicketNotifyEmail and BatchTicketNotifyEmail are marked as deprecated ([13578]), but methods of the classes are called in TicketFormatter. Is the plan to move those methods to the TicketFormatter class when TicketNotifyEmail and BatchTicketNotifyEmail are removed?

in reply to:  20 comment:21 by Peter Suter, 9 years ago

Replying to rjollos:

TicketNotifyEmail and BatchTicketNotifyEmail are marked as deprecated ([13578]), but methods of the classes are called in TicketFormatter. Is the plan to move those methods to the TicketFormatter class when TicketNotifyEmail and BatchTicketNotifyEmail are removed?

I think that's exactly what should be done, yes. (The formatting logic of those classes is perfectly fine. The problem with them was the coupling of formatting, sending and recipients gathering, with missing hooks for effective customization. Perhaps more subjectively that inheritance chain has a bit of a Yo-yo problem.)

Last edited 9 years ago by Peter Suter (previous) (diff)

comment:22 by Ryan J Ollos, 9 years ago

Thanks, I'll proposed the changes in #11901, to be applied in milestone:1.3.1.

comment:23 by Ryan J Ollos, 8 years ago

I noticed that DEBUG level logging provides no log messages to indicate that trac.ticket.notification is loading.

19:13:45 Trac[loader] DEBUG: Loading trac.ticket.admin from /Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git
19:13:45 Trac[loader] DEBUG: Loading trac.ticket.batch from /Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git
19:13:45 Trac[loader] DEBUG: Loading trac.ticket.query from /Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git
19:13:45 Trac[loader] DEBUG: Loading trac.ticket.report from /Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git
19:13:45 Trac[loader] DEBUG: Loading trac.ticket.roadmap from /Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git
19:13:45 Trac[loader] DEBUG: Loading trac.ticket.web_ui from /Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git

Would the following be advisable?

  • setup.py

    diff --git a/setup.py b/setup.py
    index 0a51fa22a..1d21222ce 100755
    a b facilities.  
    137137        trac.ticket.admin = trac.ticket.admin
    138138        trac.ticket.batch = trac.ticket.batch
    139139        trac.ticket.query = trac.ticket.query
     140        trac.ticket.notification = trac.ticket.notification
    140141        trac.ticket.report = trac.ticket.report
    141142        trac.ticket.roadmap = trac.ticket.roadmap
    142143        trac.ticket.web_ui = trac.ticket.web_ui
19:13:45 Trac[loader] DEBUG: Loading trac.ticket.notification from /Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git

In the ticket package the api and default_workflow are also excluded from entry_points, even though they have Components. I'm unsure what determines that a module should be listed in entry_points of the setup function.

comment:24 by Ryan J Ollos, 8 years ago

A few of the interfaces in tags/trac-1.2/trac/notification/api.py#L34 have the self parameter. Adding self has been discussed in the past, but other interfaces in Trac and even some in trac/notification/api.py do not have self. Should I just remove them?

comment:25 by Ryan J Ollos, 8 years ago

comment:24 changes committed to 1.2-stable in r15314, merged to trunk in r15315.

comment:26 by Ryan J Ollos, 8 years ago

comment:23 changes committed in r15603, merged to trunk in r15604.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Peter Suter.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Peter Suter 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.