mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	satifying my OCD
fire hook after successful follow/unfollow
This commit is contained in:
		| @@ -162,26 +162,29 @@ SocketUser.changePicture = function(socket, data, callback) { | |||||||
|  |  | ||||||
| SocketUser.follow = function(socket, data, callback) { | SocketUser.follow = function(socket, data, callback) { | ||||||
| 	if (socket.uid && data) { | 	if (socket.uid && data) { | ||||||
| 		plugins.fireHook('action:user.follow', { | 		toggleFollow('follow', socket.uid, data.uid, callback); | ||||||
| 			fromUid: socket.uid, |  | ||||||
| 			toUid: data.uid |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		user.follow(socket.uid, data.uid, callback); |  | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketUser.unfollow = function(socket, data, callback) { | SocketUser.unfollow = function(socket, data, callback) { | ||||||
| 	if (socket.uid && data) { | 	if (socket.uid && data) { | ||||||
| 		plugins.fireHook('action:user.unfollow', { | 		toggleFollow('unfollow', socket.uid, data.uid, callback); | ||||||
| 			fromUid: socket.uid, |  | ||||||
| 			toUid: data.uid |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		user.unfollow(socket.uid, data.uid, callback); |  | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | function toggleFollow(method, uid, theiruid, callback) { | ||||||
|  | 	user[method](uid, theiruid, function(err) { | ||||||
|  | 		if (err) { | ||||||
|  | 			return callback(err); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		plugins.fireHook('action:user.' + method, { | ||||||
|  | 			fromUid: uid, | ||||||
|  | 			toUid: theiruid | ||||||
|  | 		}); | ||||||
|  | 	}); | ||||||
|  | } | ||||||
|  |  | ||||||
| SocketUser.getSettings = function(socket, data, callback) { | SocketUser.getSettings = function(socket, data, callback) { | ||||||
| 	if (socket.uid) { | 	if (socket.uid) { | ||||||
| 		if (socket.uid === parseInt(data.uid, 10)) { | 		if (socket.uid === parseInt(data.uid, 10)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user