This is just a write up intended for discussion, implementation guidelines for the module rewrite, http://drupal.org/node/187186, and maybe parts of it can be used later for the module's documentation.
Rewriting the subscriptions framework
The first and most important part should be rewriting the subscriptions main module for it to be really extendable and escalable.
The model we are implementing should consider some elements:
- Events This is something that happens in the system and triggers the action that will lead to the users being notified of the event at the end. An event can be a node insert, update, comment posted, etc...
- Context For the same event, the user can be subscribed to it attending to different contexts. I.e. when a comment is posted, the user may be notified because he's subscribed to a the thread(node), to another user's posts (blog..) a given tag, etc...
- Queueing system For it to be really escalable, we need a powerful performance aware queueing system which should be processed using cron rather than on each page request
- Digesting and notifications As users may get several subscriptions with different sending intervals, this should handle digesting of all the notifications for the same interval, grouping them, removing duplicates (I.e. a user subscribed to a blog and to a thread and to a given tag at the same time, which may end up in multiple notifications being sent out for the same single event..)
So for a given event in the system -update, comment...-, we need to check for each user that is subscribed within each context -subscribed to the node, to the group, to the tag...- and then trigger or queue the notification action, for it to be sent to the user right away or digested for a given interval.
Split main subscriptions module
The current subscriptions module has a lot of things bundled together that may be better split in different modules, creating a 'Subscriptions' package. This will make the whole thing more modular and more extendable at the same time, as we could replace any of the modules by other/s providing similar or expanded features.
- The basic subscriptions engine. This should handle events, queing, digesting and throwing timely messages for users
- UI for managing subscriptions
- Messaging. It is about how the user will be notified, and may include several options like mail, sms...
- Different modules providing Events and Contexts
- Subscriptions to nodes/node types
- Subscriptions to taxonomy tags
- Subscriptions to comments
- Subscriptions to groups
- ....
Target features
Some features we'd like to be able to build on top of the subscriptions framework include:
- Subscription to terms in groups
- Subscription to all comments from w/in a group
- Handling of digests and de-dupe
- Flexibility to write custom listeners and subscribing to them
- Nice UI for the user, which may be an ajax interface
....
Comments
Comment #1
salvisMuch of this has been implemented, and some items are still on the TODO list, thanks!
Comment #2
salvisComment #3
felixsmile commentedAre you sure that you need to go towards cronjobs? For some kind of messaging form (sms, something else) cronjobs might not be a good solution and the site administrator might prefer an "instant" sending of the notification messages.
Just a suggestion, the rest of the features and the way to implement them simply looks great.
Felix.
Comment #4
gustav commentedYes, I think it is very important that the sending of messages is handled by the cron job because that way the user does not have to wait around while the script is communicating with the mail server. You can get a near-instantanous feeling also when using cron jobs because you can simply have the cron job run very frequently.
Comment #5
salvisI would have liked to keep the immediate sending mode, too, but it turned out that this was one major source of the problems in 1.x, especially in relation with access control modules. chx tried to implement immediate sending, but it wouldn't work, so we dropped it.
Comment #6
salvis