mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
added new hook for notification pushing
This commit is contained in:
@@ -203,6 +203,13 @@ Executed whenever a post is created or edited, after it is saved into the databa
|
|||||||
``action:post.restore``
|
``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``
|
``action:config.set``
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ var async = require('async'),
|
|||||||
events = require('./events'),
|
events = require('./events'),
|
||||||
User = require('./user'),
|
User = require('./user'),
|
||||||
groups = require('./groups'),
|
groups = require('./groups'),
|
||||||
meta = require('./meta');
|
meta = require('./meta'),
|
||||||
|
plugins = require('./plugins');
|
||||||
|
|
||||||
(function(Notifications) {
|
(function(Notifications) {
|
||||||
|
|
||||||
@@ -125,7 +126,13 @@ var async = require('async'),
|
|||||||
checkReplace(notif_data.uniqueId, uid, notif_data, function(err, replace) {
|
checkReplace(notif_data.uniqueId, uid, notif_data, function(err, replace) {
|
||||||
if (replace) {
|
if (replace) {
|
||||||
db.sortedSetAdd('uid:' + uid + ':notifications:unread', notif_data.datetime, nid);
|
db.sortedSetAdd('uid:' + uid + ':notifications:unread', notif_data.datetime, nid);
|
||||||
|
|
||||||
|
// Client-side
|
||||||
websockets.in('uid_' + uid).emit('event:new_notification', notif_data);
|
websockets.in('uid_' + uid).emit('event:new_notification', notif_data);
|
||||||
|
|
||||||
|
// Plugins
|
||||||
|
notif_data.uid = uid;
|
||||||
|
plugins.fireHook('action:notification.pushed', notif_data);
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user