Edgewall Software

Opened 9 years ago

Last modified 7 years ago

#11875 closed enhancement

Notification subscriber config section — at Version 9

Reported by: Peter Suter Owned by: Peter Suter
Priority: normal Milestone: 1.1.5
Component: notification Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Added a new [notification-subscriber] config section for general configuration of notification subscription defaults, and replacing the [notification] always_notify_* options. Added a new SubscriberListMacro.

API Changes:

Added trac.notification.api.parse_subscriber_config(), NotificationSystem.notification_subscriber_section, NotificationSystem.subscriber_defaults and NotificationSystem.default_subscriptions().

Internal Changes:

Description

Trac already has a few notification config options to control default subscriptions:

  • always_notify_updater
  • always_notify_reporter
  • always_notify_owner
  • never_notify_self (soon?)

But we don't want always_notify_close_reporter_except_when_reporter_closed_the_ticket. :)

The new INotificationSubscriber makes it easy to add new such rules, but if we provide more implementations we may actually need more config options. Also there could now be different message formats, distribution transports, default subscription priorities (and required authentication and later maybe permissions and more).

We could instead try to add a [notification-subscriber] section:

[notification-subscriber]
always_notify_updater=TicketUpdaterSubscriber
always_notify_updater.default=email, 100, always, text/plain
always_notify_reporter=TicketReportedSubscriber
always_notify_reporter.default=email, 100, always, text/plain
always_notify_owner=TicketOwnerSubscriber
always_notify_owner.default=email, 100, always, text/plain

always_notify_owner.requires_authentication=True
always_notify_owner.permission=CUSTOM_CONFIG_NOTIFY_OWNER_PERMISSION
...

(Or some equivalent notation.)

Change History (9)

comment:1 by Peter Suter, 9 years ago

Milestone: next-dev-1.1.x1.1.3
Owner: set to Peter Suter
Status: newassigned

Proposed changes in psuter.hg@T11875-notification-subrscriber-config-section.

A preliminary steps changes the interface INotificationSubscriber so default_subscriptions() also yields format (e.g. 'text/plain').

A new parse_subscriber_config() function (similar to parse_workflow_config()) parses [notification-subscriber]. The result is cached in the NotificationSystem, and used to yield default subscriptions.

An upgrade step converts the old settings:

[notification]
always_notify_owner = true
always_notify_reporter = true
always_notify_updater = false

Creating a new section:

[notification-subscriber]
always_notify_cc = CarbonCopySubscriber
always_notify_owner = TicketOwnerSubscriber
always_notify_reporter = TicketReporterSubscriber

always_notify_updater = true would add two more lines:

always_notify_updater = TicketUpdaterSubscriber
always_notify_previous_updater= TicketPreviousUpdatersSubscriber

For a future never_notify_self (#2247) one could instead append:

never_notify_self = TicketUpdaterSubscriber
never_notify_self.adverb = never

Distributor, priority and format could also be changed:

always_notify_cc_via_xmpp = CarbonCopySubscriber
always_notify_cc_via_xmpp.distributor = xmpp
always_notify_cc_via_xmpp.priority = 200
always_notify_cc_via_xmpp.format = compact

(never_notify_self might benefit from a .priority = 99.)

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

comment:2 by Peter Suter, 9 years ago

Committed preliminary refactoring in [13552]: INotificationSubscriber.default_subscriptions() now includes the format (so it can easily be configured in this proposed [notification-subscriber] section.)

comment:3 by Peter Suter, 9 years ago

Milestone: 1.1.31.1.4

comment:4 by Peter Suter, 9 years ago

Replying to jomae in #11934:

  1. Unlike options in trac.ini, no way to known easily subscriber class's name. If the section is introduced, I think we should provide subscribers wiki page like TracIni and/or subscribers manager panel in admin page.

Good idea. Maybe TracIni#notification-subscriber-section could use a [[SubscriberList]] macro?

in reply to:  4 comment:5 by Jun Omae, 9 years ago

Replying to psuter:

Good idea. Maybe TracIni#notification-subscriber-section could use a [[SubscriberList]] macro?

Yeah. Sounds good.

comment:6 by Peter Suter, 9 years ago

Updated in changeset:T11875-notification-subrscriber-config-section-2/psuter.hg with a [[SubscriberList]] macro.

comment:7 by Peter Suter, 9 years ago

Milestone: 1.1.41.1.5

Looks like a bunch of tests need an update.

comment:8 by Peter Suter, 9 years ago

In log:psuter.hg@T11875_notification_subscriber_config_section_3:

  • Updated tests
  • Default settings: I assume for new environments [notification-subscriber] should have defaults equivalent to the previous [notification] always_notify_* defaults, mirroring the upgrade step. So far the only ConfigSection with default values seem to be [ticket-workflow] (which has a custom IEnvironmentSetupParticipant) and [repositories] (which has special handling in trac-admin initenv).
  • Invalidate cache: If the parsed subscriber configuration is cached, that cache must be invalidated, or configuration changes have no effect.

comment:9 by Peter Suter, 9 years ago

API Changes: modified (diff)
Release Notes: modified (diff)
Note: See TracTickets for help on using tickets.