Merge remote-tracking branch 'origin/master' into 0.7.0

v1.18.x
barisusakli 10 years ago
commit feeeb83a43

@ -47,15 +47,21 @@ SocketPosts.reply = function(socket, data, callback) {
socket.emit('event:new_post', result); socket.emit('event:new_post', result);
SocketPosts.notifyOnlineUsers(socket.uid, result);
});
};
SocketPosts.notifyOnlineUsers = function(uid, result) {
var cid = result.posts[0].topic.cid;
async.waterfall([ async.waterfall([
function(next) { function(next) {
user.getUidsFromSet('users:online', 0, -1, next); user.getUidsFromSet('users:online', 0, -1, next);
}, },
function(uids, next) { function(uids, next) {
privileges.categories.filterUids('read', postData.topic.cid, uids, next); privileges.categories.filterUids('read', cid, uids, next);
}, },
function(uids, next) { function(uids, next) {
plugins.fireHook('filter:sockets.sendNewPostToUids', {uidsTo: uids, uidFrom: data.uid, type: 'newPost'}, next); plugins.fireHook('filter:sockets.sendNewPostToUids', {uidsTo: uids, uidFrom: uid, type: 'newPost'}, next);
} }
], function(err, data) { ], function(err, data) {
if (err) { if (err) {
@ -65,12 +71,11 @@ SocketPosts.reply = function(socket, data, callback) {
var uids = data.uidsTo; var uids = data.uidsTo;
for(var i=0; i<uids.length; ++i) { for(var i=0; i<uids.length; ++i) {
if (parseInt(uids[i], 10) !== socket.uid) { if (parseInt(uids[i], 10) !== uid) {
websockets.in('uid_' + uids[i]).emit('event:new_post', result); websockets.in('uid_' + uids[i]).emit('event:new_post', result);
} }
} }
}); });
});
}; };
SocketPosts.getVoters = function(socket, data, callback) { SocketPosts.getVoters = function(socket, data, callback) {

Loading…
Cancel
Save