feat: add hook for user notifications, closes #7672

This commit is contained in:
Barış Soner Uşaklı
2019-06-13 10:18:02 -04:00
parent 89fea9d375
commit ede060a646
2 changed files with 12 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ var db = require('../database');
var meta = require('../meta');
var notifications = require('../notifications');
var privileges = require('../privileges');
var plugins = require('../plugins');
var utils = require('../utils');
var UserNotifications = module.exports;
@@ -111,7 +112,7 @@ function getNotificationsFromSet(set, uid, start, stop, callback) {
UserNotifications.getNotifications = function (nids, uid, callback) {
if (!Array.isArray(nids) || !nids.length) {
return callback(null, []);
return setImmediate(callback, null, []);
}
var notificationData = [];
@@ -145,6 +146,14 @@ UserNotifications.getNotifications = function (nids, uid, callback) {
function (next) {
notifications.merge(notificationData, next);
},
function (notifications, next) {
plugins.fireHook('filter:user.notifications.getNotifications', {
uid: uid,
notifications: notifications,
}, function (err, result) {
next(err, result && result.notifications);
});
},
], callback);
};