mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	notifyOnlineUsers helper
This commit is contained in:
		| @@ -47,15 +47,21 @@ SocketPosts.reply = function(socket, data, callback) { | ||||
|  | ||||
| 		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([ | ||||
| 		function(next) { | ||||
| 			user.getUidsFromSet('users:online', 0, -1, next); | ||||
| 		}, | ||||
| 		function(uids, next) { | ||||
| 				privileges.categories.filterUids('read', postData.topic.cid, uids, next); | ||||
| 			privileges.categories.filterUids('read', cid, 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) { | ||||
| 		if (err) { | ||||
| @@ -65,12 +71,11 @@ SocketPosts.reply = function(socket, data, callback) { | ||||
| 		var uids = data.uidsTo; | ||||
|  | ||||
| 		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); | ||||
| 			} | ||||
| 		} | ||||
| 	}); | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| SocketPosts.getVoters = function(socket, data, callback) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user