Skip to content

Node.js based forum software built for the modern web

added new hook for notification pushing

Julian Lamdedc6d8154a1
diff --git a/docs/plugins/hooks.rst b/docs/plugins/hooks.rst
index bfba67baad..672b0743ed 100644
--- a/docs/plugins/hooks.rst
+++ b/docs/plugins/hooks.rst
@@ -203,6 +203,13 @@ Executed whenever a post is created or edited, after it is saved into the databa
``action:post.restore``
^^^^^^^^^^^^^^^^^^^^^
+``action:notification.pushed``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+**Argument(s)**: A notification object (javascript Object)
+
+Executed whenever a notification is pushed to a user.
+
``action:config.set``
^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/notifications.js b/src/notifications.js
index 8f07dc2cf1..3912d2cd22 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -11,7 +11,8 @@ var async = require('async'),
events = require('./events'),
User = require('./user'),
groups = require('./groups'),
- meta = require('./meta');
+ meta = require('./meta'),
+ plugins = require('./plugins');
(function(Notifications) {
@@ -125,7 +126,13 @@ var async = require('async'),
checkReplace(notif_data.uniqueId, uid, notif_data, function(err, replace) {
if (replace) {
db.sortedSetAdd('uid:' + uid + ':notifications:unread', notif_data.datetime, nid);
+
+ // Client-side
websockets.in('uid_' + uid).emit('event:new_notification', notif_data);
+
+ // Plugins
+ notif_data.uid = uid;
+ plugins.fireHook('action:notification.pushed', notif_data);
}
next();
});