[Plugin] Notifications system (1.0)

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Notifications system (1.0)
« on June 10th, 2012, 08:14 PM »
I thought I'd announce this before I go, anyway, I've been working on a full fledged notifications of Wedge which is meant to serve as a replacement for all the existing notification with a fully pluggable notifications system.

The system plugin by default provides no notifications, but various plugin that will come with it that provides notifications for various actions. Currently implemented features:

- Allow plugins to easily issue notifications without much hassle
- Provide the user an easy interface to view those and mark as read, currently it's displaying 5 latest unread notifications on the sidebar with an option to view all notifications. The notifications are marked as read automatically as soon as they're clicked.
- Allow individual notifiers to be disabled per user, i.e. an user can choose to not receive notification for topic replies etc.
- Allow notifiers to send e-mails for notifications, which can be disabled on a per notifier basis by the user
- Allow e-mails to be received instantly, daily or weekly (not implemented yet)

The aim of the system is to provide an easy API for plugins to notify users without having to re-implement all the features again. Plus it provides a centralized system for receiving/viewing notifications.

Notification extensions
These plugins use the notifications core to issue notifications in various events, the notifications core itself is useless. These can be used as a sample for notification extensions

ID: Dragooon:WeNotif-TopicReply

Notifies the author of a reply to their topic

ID: Dragooon:WeNotif-Quote

Notifies the author if someone has quoted their post

I'll be working on replacing the existing notifications next, by providing plugins that mimic the funcionality but work full and well with the notification system.

 SS3.png - 23.23 kB, 961x474, viewed 422 times.

 SS2.png - 8.57 kB, 982x175, viewed 401 times.

 SS1.png - 7.25 kB, 249x225, viewed 419 times.

The way it's meant to be

Dismal Shadow

  • Madman in a Box
  • Me: Who is Arantor? Cleverbot: It stands for time and relative dimensions in space.
  • Posts: 1,185
“I will stand on my ground as an atheist until your god shows up...If my irreligious bothers you much, and if you think everything I do is heresy to your god I don't care. Heresy is for those who believe, I don't. So, it isn't heresy at all!


   Jack in, Wedge,
   EXECUTE!

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Re: Notifications system (1.0)
« Reply #2, on June 11th, 2012, 05:14 PM »
Quote from Nathan Sparrow on June 11th, 2012, 05:33 AM
Nice & elegant. :)

Does this have any impact the server?
It has some impact due to additional queries, but I'm trying to be very careful about minimizing any extra load and optimizing it as much as I can, plus I'm also utilizing caching wherever I can.
[Plugin] Re: Notifications system (1.0)
« Reply #3, on January 13th, 2013, 01:55 PM »
Just wanted to give this topic a bump, I'm still working on it (whenever I can, hardly getting time these days due to exams, then SMF4Mobile and all).  I wanted some opinions on what you guys think about the core plugin and all.

Some terminology, so that people don't get confused later.
Notifier: This is the object that actually issues notifications. For example, TopicReply is a notifier that issues notifications whenever a replied is posted to a person's topic.
Notification: Pretty obvious, individual messages sent to people to tell what's going on
NotifSubscriber: I probably need a better name for this, short for Notification Subscriber, this is another object which handles individual types of subscription. For example, there can be a subscriber for Board which handles sending out subscription notifications for any new topic in a specific board.

Basically, currently the core of notifications is divided into two. First is handling the notifications themselves, it allows plugins to have notifier and issue notifications to user. It also handles disabling of specific notifiers, individual preferences (if any) etc. in a single profile page. The second part handles subscriptions, basically anything that the user isn't directly linked to but wants to get an update of (same as current Wedge subscriptions). Subscription part is build on top of the notification core and is optional, it obviously aims at replacing the current mess of a subscription Wedge (and, by extension, SMF) has with a simpler UI and more modularity. My aim is to make the subscription option themselves simpler, an user can subscribe to a specific topic and see his or her subscription info from their profile, and remove them if they want. The advance notifying stuff (stuff like e-mail once every week etc.) gets moved to the notifications core. This way, other notifier can also, by default, take advantage of having some nice e-mailing options.

Currently subscriptions are divided into two parts, so one needs to code these two in order to add a new subscriptions . First is their subscriber, and second is their notifier. Subscriber handles all the subscription part of the equation, i.e. validating of topic (for example) they're trying to subscribe to  and issuing subscription notifications themselves whenever required (like when a new topic is posted). Notifier handles the notifications of the subscription, i.e. what to actually say when a notification is issued, what to do when there are multiple unread notifications of the same type, and notifier specific preferences (this is valid to other types of notifier as well and not only subscriptions).

To give an elaborate example for a subscription, if someone needs to create a plugin where anyone is notified when a specific user is quoted in a post (probably a stupid idea, but it gets the point across). A member will subscribe to another member to receive the notifications. One will firstly code the notifier itself. The notifier will have a few functions, firstly to return what the text should say for a specific notification, the e-mail text etc. and what to do if there are multiple unread notifications of the same type (so that it can say "admin has been quoted in "Re: Test" and 4 other messages"). Then comes the subscriber, which will handle identifying the subscriber itself (for internal purposes) and validating the member when someone is trying to subscribe to them, i.e. whether the member is valid and can be subscribed too or not. The plugin then will hook to post_form (or whichever hook is called after a post has been created),  and check if a member has been quoted, and if there has been a member who's been quoted, it will issue all the subscription notifications. The issuing part is mostly simple, you just need to call a function, say which subscriber you are (memberquote in this case) and for which object are notifications being issued (the member who has been quoted in this case) and pass any arbitrary data (post subject, etc.) that can be useful when displaying notification. The internal function (part of the core plugin, already coded, no need to code anything more here) will handle actually sending out the notifications to whoever has subscribed to that specific member. The plugin will also hook to appropriate places to add the button/UI for providing a link to actually subscribe to the place (the subscription action is handled by the core, but the UI is provided by the plugin which is adding a subscriber since it can be at any number of places).

I already have a couple of examples for simple notifiers, see them in my GH repository.

This can be a fairly bit complex to explain without code examples, but any feedback is appreciated. Is it too complex to extend? Any ideas which can probably make it simpler? Any examples of other systems which already do this and work well? Thanks :)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
[Plugin] Re: Notifications system (1.0)
« Reply #4, on January 13th, 2013, 03:52 PM »
I think it's kind of hard to judge this without actually trying to make something myself with it.

Mind you, I've been of the opinion that we might need to add something along these lines into the core sometime.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Pandos

  • Living on the edge of Wedge
  • Posts: 635
[Plugin] Re: Notifications system (1.0)
« Reply #5, on January 14th, 2013, 10:43 AM »
Love this idea!
In my case we're using an external CMS. Layout works over SSI. So the comments and replys to an article made in the cms will be recognized . Very cool!
# dpkg-reconfigure brain
error: brain is not installed or configured

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Re: Notifications system (1.0)
« Reply #6, on January 14th, 2013, 11:51 AM »
Quote from Arantor on January 13th, 2013, 03:52 PM
I think it's kind of hard to judge this without actually trying to make something myself with it.

Mind you, I've been of the opinion that we might need to add something along these lines into the core sometime.
Fair enough, hopefully you'll be able to make something yourself soon.
Quote from Pandos on January 14th, 2013, 10:43 AM
Love this idea!
In my case we're using an external CMS. Layout works over SSI. So the comments and replys to an article made in the cms will be recognized . Very cool!
Ofcourse, you'll need to code that part :)
[Plugin] Re: Notifications system (1.0)
« Reply #7, on January 20th, 2013, 12:39 AM »
Okay, this is the first working example of a subscription plugin: https://github.com/Dragooon/WeNotif-Subs-Topics

It allows one to subscribe to topics, coded in about 30 minutes at 4:30 AM so it's still very rough and a bunch of things are still left to do, but it seems to be working fairly fine. You can see how a subscriber is implemented, this should give a nice example of one.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Re: Notifications system (1.0)
« Reply #9, on January 20th, 2013, 08:57 AM »
Quote from Arantor on January 20th, 2013, 01:32 AM
Shiny :)
Yup :), it's working out okay. The core plugins still need a lot of work (I need to work on it during daytime more, the code needs tidying up), but the basic structure should remain same. The topics extension is more or less complete, I don't think it should need anything more except a couple of things that are todo, what do you think of the code (simplicity wise) itself? It's a complete implementation for topic subscription, any other plugin will have to do similar things to add their own notification subscriptions.

agent47

  • Now I see the changes you're talking about.
  • Posts: 115
[Plugin] Re: Notifications system (1.0)
« Reply #10, on January 20th, 2013, 10:02 AM »
Tried to give this plugin a test but got this error:
Quote
This plugin cannot be used because:
One or more features required by this plugin are not available. (notification_callback, notification_subscription)

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Re: Notifications system (1.0)
« Reply #11, on January 20th, 2013, 03:24 PM »
Quote from agent47 on January 20th, 2013, 10:02 AM
Tried to give this plugin a test but got this error:
Quote
This plugin cannot be used because:
One or more features required by this plugin are not available. (notification_callback, notification_subscription)
You also need to enable WeNotif and WeNotif-Subs before being able to enable this plugin. And I seriously don't recommend trying it out just now, it's still very early in development.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
[Plugin] Re: Notifications system (1.0)
« Reply #12, on January 20th, 2013, 03:26 PM »
Yay for a plugin system that won't let you install plugins without dependencies being met. :)

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Re: Notifications system (1.0)
« Reply #13, on March 10th, 2013, 08:34 AM »
Ahah, this is the public topic....reminder: implement the option to automatically subscribe to your threads.

Also, for the others:
Quote
I know the plugin uses the sidebar but I'm not entirely convinced that's workable at present - I would never, ever see my own notifications on the desktop because I have my window sized at around 1000px, gives me enough room for dual pane work, but has the side effect that the sidebar is pushed to the bottom. Makes me wonder about having something up in the header area for the user.
Okay, this is one of the last issues I'd like to work out before giving it a go for installation on a live site for testing, any ideas where this can go? I'm thinking either:
1) Make a big number counter next to the site's title
2) Make a menu entry and display the counter there, which expands to show quick unread notification with the option to show all.
3) Make some sort of floating box?

EDIT: I'd like any suggestion anyone has

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
[Plugin] Re: Notifications system (1.0)
« Reply #14, on March 10th, 2013, 04:25 PM »
What I'd be inclined to do is move the user info bit out of the sidebar and up into the top right under the search area, and put notifications up there.