Notification System
Zine needs an internal notification system that can be used to send human readable notifications to notification systems (email, jabber, sms etc.) that the core and plugins can use.
Why do we need it?
- Authors want to know when comments appear in the moderation queue
- Administrators want to know when a new Zine upgrade is available
- Plugins want to use the notification system to notify about things they monitor (eg: check if wikipedia is down)
What are the requirements?
- Plugins have to be able to notify and handle notifications (eg: a plugin implements a notification service that sends a twitter message)
- Each user should be able to tick and untick what he wants to be notified about and how
- Joe wants an EMail when a new comment is posted, whereas Susi wants a SMS and both want a Jabber message
Conclusions
- We need to provide some add_notification_system() method that allows adding notification plugins (that implement a common abstract base class). In its setup method the notification plugin adds itself as "notifyer". These plugins should only contain code responsible for actually sending notifications and not aim to provide monitoring facilities.
- We need to provide means to add monitoring plugins that send messages either on certain events or periodically using a send_notification() method.
- Notification systems only do one thing: They deliver $message to $user. Nothing else. Stupidly.
- We keep a database table of the following format: user | notification_system | when_to_send_the_notification
- A NotificationManager makes use of the notification systems and, when $notification should be sent, checks the database table which user receives $notification via which systems and passes $notification to the systems with the users adress/JID/phone number for final delivery
- We need a class for notification so we can do things like notification.title and notification.body
Sketching up the API
Components we need at least:
- app.add_notification_system()
- Example usage: app.add_notification_system(JabberNotifyer)
- send_notification(notification)
- Example usage: send_notification(notification)
- class Notification
- Example usage: n = Notification("title", "message body")
- Adding a receipients-list to notifications is not a good idea. A notification should not care which systems delivers it and we may have users registered for email-notifications but not for jabber-notifications.