Edgewall Software
Modify

Opened 12 years ago

Closed 4 years ago

Last modified 22 months 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
Release Notes:

Allow plugins to extend notification system.

API Changes:

Added new API for notification distribution and extension points:

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@… 12 years ago.
Example of submitting messages to CIA from trac
trac-0.10-cia.diff (4.6 KB ) - added by wichert@… 11 years ago.
CIA for trac 0.10.4
trac-0.10.4-cia.diff (5.6 KB ) - added by wichert@… 11 years ago.
CIA for trac 0.10.4

Download all attachments as: .zip

Change History (29)

Changed 12 years ago by wichert@…

Attachment: trac-cia.diff added

Example of submitting messages to CIA from trac

comment:1 Changed 12 years ago by wichert@…

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 Changed 12 years ago by Christian Boos

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 Changed 11 years ago by Pedro Algarvio, aka, s0undt3ch <ufs@…>

Cc: ufs@… added

comment:4 Changed 11 years ago by pookey@…

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 Changed 11 years ago by wichert@…

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

Changed 11 years ago by wichert@…

Attachment: trac-0.10-cia.diff added

CIA for trac 0.10.4

Changed 11 years ago by wichert@…

Attachment: trac-0.10.4-cia.diff added

CIA for trac 0.10.4

comment:6 Changed 11 years ago by davidf@…

Cc: davidf@… added

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

comment:7 Changed 11 years ago by anonymous

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.

comment:8 in reply to:  6 Changed 11 years ago by Emmanuel Blot

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 Changed 10 years ago by wichert@…

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 Changed 10 years ago by John Hampton

Cc: pacopablo@… added

comment:11 Changed 5 years ago by Peter Suter

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 Changed 5 years ago by Peter Suter

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

comment:13 Changed 5 years ago by Jun Omae

Cc: Jun Omae added

comment:14 Changed 5 years ago by Ryan J Ollos

Milestone: 1.1.21.1.3

comment:15 in reply to:  11 Changed 4 years ago by Peter Suter

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 Changed 4 years ago by Peter Suter

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))

comment:18 in reply to:  17 Changed 4 years ago by Ryan J Ollos

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 4 years ago by Ryan J Ollos (previous) (diff)

comment:19 in reply to:  16 Changed 4 years ago by Peter Suter

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 Changed 3 years ago by Ryan J Ollos

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?

comment:21 in reply to:  20 Changed 3 years ago by Peter Suter

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 3 years ago by Peter Suter (previous) (diff)

comment:22 Changed 3 years ago by Ryan J Ollos

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

comment:23 Changed 2 years ago by Ryan J Ollos

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 Changed 2 years ago by Ryan J Ollos

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 Changed 2 years ago by Ryan J Ollos

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

comment:26 Changed 22 months ago by Ryan J Ollos

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.
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.