Following #1549442: Use Message API for Activity stream functionality and #1551368: Use Message notify for email notifications, it's time for a more detailed plan on how to use these modules.
The proposed Commons notification system allows users to receive updates in their activity stream as well as by email. The currently proposed verb for creating a subscription is to "follow" but this could change to "subscribe" or something similar.
Users can configure their subscriptions in a single UI, and subscribe to taxonomy groups, comments and edits on individual nodes, as as users. Individual entities that the user can subscribe to have ajax toggle links .
Correction: The tabs in this screenshot actually correspond to Flags, not message types.
Overall, this breaks down into 3 kinds of functionality:
- Generating messages for events & showing the right messages in the right context (e.g., site wide stream vs group-specific stream)
- Allowing users to subscribe (Flag) to nodes users, and taxonomy terms in a given vocabulary
- Sending emails to subscribed users
Proposed breakdown of functionality across modules:
Commons_follow_* - Underlying modules for flagging the subscription.
- Exported flags to flag nodes, groups, users, taxonomy terms
- Config to limit flagging of terms to specific vocabularies (Flag may support this already)
- Foundational code in place at http://drupal.org/project/commons_follow_users http://drupal.org/project/commons_follow_group http://drupal.org/project/commons_follow_node http://drupal.org/project/commons_follow_term
- Filter a view of content based on content, users, groups, terms you're following
- Filter a view of messages (activity stream) per:
-- Related group (likely determined by joining against the nid being acted upon, in part to simplify when a node changes groups and there are existing activity messages about that node)
-- Relevant node being acted upon (versus group?)
--Acting User (Store in message field)
-- Post mvp: per-topic
Commons_follow_UI (Depends on commons_follow):
(Likely one central commons_follow_UI module that the commons_follow_* modules can extend.
- Central UI to manage subscriptions (stream and email) that are defined by other modules.
- Other modules add controls to that UI via an API - Other modules likely define:
- - Message type(s) that should be visible in the UI. Generates a tab (likely QuickTabs) for each one
- - Embeds a View (the control UI) in each Quicktab
- A variable specifies the default view to use for these tabs (initially one View for all tabs. Could later support different views for different types of subscriptions)
- Other modules can extend the specific view via export alters. (Eg, radioactivity to add "Last Activity" column)
- Business logic to disable the unsubscribe link on an entity when an existing subscription overlaps with the current entity (e.g., user is subscribed to a taxonomy term assigned to the current node: that user can't follow or unfollow the node, because she is already subscribed via the term subscription)
Commons_streams (depends on commons_follow)
- Define stream message types (see below) - Store acting user and target entity.
- Batch generate messages for past events up to a certain period back (e.g., for upgrading sites)
- Support TimeAgo to update timestamps for messages (http://drupal.org/project/timeago) (Also simplifies showing an "Ago" format in cached content)
- Potentially: Index activity stream messages via ApacheSolr to speed up entity-specific streams (e.g. group)
Commons_notify (Depends on Commons_streams)
- Define email notification message types
- Relate each message type to the corresponding type defined by commons_streams (e.g., email notifications for the "comment_insert" message type)
- Store subscribed/unsubscribed for mail delivery option. Perhaps another (internal) Flag?
- Queue & send email notifications based on subscriptions defined in Commons_follow
- Integrate the unsubscribe from email control into the Commons_follow UI (likely by adding a field to the view)
Initial list of message types
For the Commons MVP, we'll generate a message for the following kinds of site activity:
- Node is created
- Wiki Node is updated
- New Comment
- Content is +1'd
- User follows another user
- User updates profile
Example notification event
Example notification event:
Bob subscribes to:
- NYC (group)
- Cakes (taxonomy term)
- Jane (user)
Jane posts "Checkout these great cakes in NYC":
* Commons_streams: Create the stream message
* Commons_notify: Queue this action for processing based on existing Message templates created.
* Process the queued event - Find all users subscribed via (all defined subscription types):
* Uids by group
* Uids by Topic
* Uids by Person
* Queue jobs to send message to all UIDs subscribed