Add more messaging hooks

This commit is contained in:
Peter Jaszkowiak
2017-04-26 10:45:40 -06:00
parent 3350a89791
commit 42e21d5aa9
3 changed files with 38 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ var emailer = require('../emailer');
var notifications = require('../notifications');
var meta = require('../meta');
var sockets = require('../socket.io');
var plugins = require('../plugins');
module.exports = function (Messaging) {
Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser
@@ -27,6 +28,15 @@ module.exports = function (Messaging) {
message: messageObj,
};
plugins.fireHook('filter:messaging.notifyUsersInRoom', data, next);
},
function (data, next) {
if (!data || !data.uids || !data.uids.length) {
return next();
}
var uids = data.uids;
uids.forEach(function (uid) {
data.self = parseInt(uid, 10) === parseInt(fromUid, 10) ? 1 : 0;
Messaging.pushUnreadCount(uid);