mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	added some missing callbacks
This commit is contained in:
		| @@ -8,7 +8,7 @@ var	async = require('async'), | |||||||
| 	plugins = require('../plugins'), | 	plugins = require('../plugins'), | ||||||
| 	widgets = require('../widgets'), | 	widgets = require('../widgets'), | ||||||
| 	user = require('../user'), | 	user = require('../user'), | ||||||
| 	posts = require('../posts'), |  | ||||||
| 	logger = require('../logger'), | 	logger = require('../logger'), | ||||||
| 	events = require('../events'), | 	events = require('../events'), | ||||||
| 	emailer = require('../emailer'), | 	emailer = require('../emailer'), | ||||||
| @@ -60,6 +60,7 @@ SocketAdmin.reload = function(socket, data, callback) { | |||||||
| 		process.send({ | 		process.send({ | ||||||
| 			action: 'reload' | 			action: 'reload' | ||||||
| 		}); | 		}); | ||||||
|  | 		callback(); | ||||||
| 	} else { | 	} else { | ||||||
| 		meta.reload(callback); | 		meta.reload(callback); | ||||||
| 	} | 	} | ||||||
| @@ -72,10 +73,12 @@ SocketAdmin.restart = function(socket, data, callback) { | |||||||
| 		ip: socket.ip | 		ip: socket.ip | ||||||
| 	}); | 	}); | ||||||
| 	meta.restart(); | 	meta.restart(); | ||||||
|  | 	callback(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketAdmin.fireEvent = function(socket, data, callback) { | SocketAdmin.fireEvent = function(socket, data, callback) { | ||||||
| 	index.server.emit(data.name, data.payload || {}); | 	index.server.emit(data.name, data.payload || {}); | ||||||
|  | 	callback(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketAdmin.themes.getInstalled = function(socket, data, callback) { | SocketAdmin.themes.getInstalled = function(socket, data, callback) { | ||||||
| @@ -83,7 +86,7 @@ SocketAdmin.themes.getInstalled = function(socket, data, callback) { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketAdmin.themes.set = function(socket, data, callback) { | SocketAdmin.themes.set = function(socket, data, callback) { | ||||||
| 	if(!data) { | 	if (!data) { | ||||||
| 		return callback(new Error('[[error:invalid-data]]')); | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -134,16 +137,16 @@ SocketAdmin.widgets.set = function(socket, data, callback) { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketAdmin.config.set = function(socket, data, callback) { | SocketAdmin.config.set = function(socket, data, callback) { | ||||||
| 	if(!data) { | 	if (!data) { | ||||||
| 		return callback(new Error('[[error:invalid-data]]')); | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	meta.configs.set(data.key, data.value, function(err) { | 	meta.configs.set(data.key, data.value, function(err) { | ||||||
| 		if(err) { | 		if (err) { | ||||||
| 			return callback(err); | 			return callback(err); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		callback(null); | 		callback(); | ||||||
|  |  | ||||||
| 		plugins.fireHook('action:config.set', { | 		plugins.fireHook('action:config.set', { | ||||||
| 			key: data.key, | 			key: data.key, | ||||||
| @@ -155,7 +158,7 @@ SocketAdmin.config.set = function(socket, data, callback) { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketAdmin.config.setMultiple = function(socket, data, callback) { | SocketAdmin.config.setMultiple = function(socket, data, callback) { | ||||||
| 	if(!data) { | 	if (!data) { | ||||||
| 		return callback(new Error('[[error:invalid-data]]')); | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -179,8 +182,9 @@ SocketAdmin.config.setMultiple = function(socket, data, callback) { | |||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketAdmin.config.remove = function(socket, key) { | SocketAdmin.config.remove = function(socket, key, callback) { | ||||||
| 	meta.configs.remove(key); | 	meta.configs.remove(key); | ||||||
|  | 	callback(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketAdmin.settings.get = function(socket, data, callback) { | SocketAdmin.settings.get = function(socket, data, callback) { | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ SocketNotifs.loadMore = function(socket, data, callback) { | |||||||
| 		return callback(new Error('[[error:invalid-data]]')); | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} | 	} | ||||||
| 	if (!socket.uid) { | 	if (!socket.uid) { | ||||||
| 		return; | 		return callback(new Error('[[error:no-privileges]]')); | ||||||
| 	} | 	} | ||||||
| 	var start = parseInt(data.after, 10); | 	var start = parseInt(data.after, 10); | ||||||
| 	var stop = start + 20; | 	var stop = start + 20; | ||||||
| @@ -37,7 +37,7 @@ SocketNotifs.getCount = function(socket, data, callback) { | |||||||
|  |  | ||||||
| SocketNotifs.deleteAll = function(socket, data, callback) { | SocketNotifs.deleteAll = function(socket, data, callback) { | ||||||
| 	if (!socket.uid) { | 	if (!socket.uid) { | ||||||
| 		return; | 		return callback(new Error('[[error:no-privileges]]')); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	user.notifications.deleteAll(socket.uid, callback); | 	user.notifications.deleteAll(socket.uid, callback); | ||||||
| @@ -57,7 +57,7 @@ SocketNotifs.markAllRead = function(socket, data, callback) { | |||||||
|  |  | ||||||
| SocketNotifs.generatePath = function(socket, nid, callback) { | SocketNotifs.generatePath = function(socket, nid, callback) { | ||||||
| 	if (!socket.uid) { | 	if (!socket.uid) { | ||||||
| 		return; | 		return callback(new Error('[[error:no-privileges]]'));; | ||||||
| 	} | 	} | ||||||
| 	async.waterfall([ | 	async.waterfall([ | ||||||
| 		function (next) { | 		function (next) { | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ var	SocketPlugins = {}; | |||||||
|  |  | ||||||
| 		var SocketPlugins = require.main.require('./src/socket.io/plugins'); | 		var SocketPlugins = require.main.require('./src/socket.io/plugins'); | ||||||
| 		SocketPlugins.myPlugin = {}; | 		SocketPlugins.myPlugin = {}; | ||||||
| 		SocketPlugins.myPlugin.myMethod = function() { ... }; | 		SocketPlugins.myPlugin.myMethod = function(socket, data, callback) { ... }; | ||||||
|  |  | ||||||
| 	Be a good lad and namespace your methods. | 	Be a good lad and namespace your methods. | ||||||
| */ | */ | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ module.exports = function(SocketTopics) { | |||||||
|  |  | ||||||
| 	SocketTopics.loadTopicTools = function(socket, data, callback) { | 	SocketTopics.loadTopicTools = function(socket, data, callback) { | ||||||
| 		if (!socket.uid) { | 		if (!socket.uid) { | ||||||
| 			return; | 			return callback(new Error('[[error:no-privileges]]')); | ||||||
| 		} | 		} | ||||||
| 		if (!data) { | 		if (!data) { | ||||||
| 			return callback(new Error('[[error:invalid-data]]')); | 			return callback(new Error('[[error:invalid-data]]')); | ||||||
| @@ -74,7 +74,7 @@ module.exports = function(SocketTopics) { | |||||||
| 	SocketTopics.doTopicAction = function(action, event, socket, data, callback) { | 	SocketTopics.doTopicAction = function(action, event, socket, data, callback) { | ||||||
| 		callback = callback || function() {}; | 		callback = callback || function() {}; | ||||||
| 		if (!socket.uid) { | 		if (!socket.uid) { | ||||||
| 			return; | 			return callback(new Error('[[error:no-privileges]]')); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (!data || !Array.isArray(data.tids) || !data.cid) { | 		if (!data || !Array.isArray(data.tids) || !data.cid) { | ||||||
|   | |||||||
| @@ -23,14 +23,15 @@ require('./user/picture')(SocketUser); | |||||||
| require('./user/ban')(SocketUser); | require('./user/ban')(SocketUser); | ||||||
|  |  | ||||||
| SocketUser.exists = function(socket, data, callback) { | SocketUser.exists = function(socket, data, callback) { | ||||||
| 	if (data && data.username) { | 	if (!data || !data.username) { | ||||||
| 		meta.userOrGroupExists(data.username, callback); | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} | 	} | ||||||
|  | 	meta.userOrGroupExists(data.username, callback); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketUser.deleteAccount = function(socket, data, callback) { | SocketUser.deleteAccount = function(socket, data, callback) { | ||||||
| 	if (!socket.uid) { | 	if (!socket.uid) { | ||||||
| 		return; | 		return callback(new Error('[[error:no-privileges]]')); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	async.waterfall([ | 	async.waterfall([ | ||||||
| @@ -58,25 +59,27 @@ SocketUser.deleteAccount = function(socket, data, callback) { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketUser.emailExists = function(socket, data, callback) { | SocketUser.emailExists = function(socket, data, callback) { | ||||||
| 	if (data && data.email) { | 	if (!data || !data.email) { | ||||||
| 		user.email.exists(data.email, callback); | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} | 	} | ||||||
|  | 	user.email.exists(data.email, callback); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketUser.emailConfirm = function(socket, data, callback) { | SocketUser.emailConfirm = function(socket, data, callback) { | ||||||
| 	if (socket.uid && parseInt(meta.config.requireEmailConfirmation, 10) === 1) { | 	if (!socket.uid) { | ||||||
| 		user.getUserField(socket.uid, 'email', function(err, email) { | 		return callback(new Error('[[error:no-privileges]]')); | ||||||
| 			if (err) { |  | ||||||
| 				return callback(err); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 			if (!email) { | 	if (parseInt(meta.config.requireEmailConfirmation, 10) !== 1) { | ||||||
| 				return; | 		callback(); | ||||||
|  | 	} | ||||||
|  | 	user.getUserField(socket.uid, 'email', function(err, email) { | ||||||
|  | 		if (err || !email) { | ||||||
|  | 			return callback(err); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		user.email.sendValidationEmail(socket.uid, email, callback); | 		user.email.sendValidationEmail(socket.uid, email, callback); | ||||||
| 	}); | 	}); | ||||||
| 	} |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -84,9 +87,11 @@ SocketUser.emailConfirm = function(socket, data, callback) { | |||||||
| SocketUser.reset = {}; | SocketUser.reset = {}; | ||||||
|  |  | ||||||
| SocketUser.reset.send = function(socket, email, callback) { | SocketUser.reset.send = function(socket, email, callback) { | ||||||
| 	if (email) { | 	if (!email) { | ||||||
| 		user.reset.send(email, callback); | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	user.reset.send(email, callback); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketUser.reset.commit = function(socket, data, callback) { | SocketUser.reset.commit = function(socket, data, callback) { | ||||||
| @@ -102,9 +107,9 @@ SocketUser.reset.commit = function(socket, data, callback) { | |||||||
| 			return callback(err); | 			return callback(err); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		var uid = results.uid, | 		var uid = results.uid; | ||||||
| 			now = new Date(), | 		var now = new Date(); | ||||||
| 			parsedDate = now.getFullYear() + '/' + (now.getMonth()+1) + '/' + now.getDate(); | 		var parsedDate = now.getFullYear() + '/' + (now.getMonth()+1) + '/' + now.getDate(); | ||||||
|  |  | ||||||
| 		user.getUserField(uid, 'username', function(err, username) { | 		user.getUserField(uid, 'username', function(err, username) { | ||||||
| 			emailer.send('reset_notify', uid, { | 			emailer.send('reset_notify', uid, { | ||||||
| @@ -134,7 +139,7 @@ SocketUser.isFollowing = function(socket, data, callback) { | |||||||
|  |  | ||||||
| SocketUser.follow = function(socket, data, callback) { | SocketUser.follow = function(socket, data, callback) { | ||||||
| 	if (!socket.uid || !data) { | 	if (!socket.uid || !data) { | ||||||
| 		return; | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} | 	} | ||||||
| 	var userData; | 	var userData; | ||||||
| 	async.waterfall([ | 	async.waterfall([ | ||||||
| @@ -165,9 +170,10 @@ SocketUser.follow = function(socket, data, callback) { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketUser.unfollow = function(socket, data, callback) { | SocketUser.unfollow = function(socket, data, callback) { | ||||||
| 	if (socket.uid && data) { | 	if (!socket.uid || !data) { | ||||||
| 		toggleFollow('unfollow', socket.uid, data.uid, callback); | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} | 	} | ||||||
|  | 	toggleFollow('unfollow', socket.uid, data.uid, callback); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| function toggleFollow(method, uid, theiruid, callback) { | function toggleFollow(method, uid, theiruid, callback) { | ||||||
| @@ -206,15 +212,17 @@ SocketUser.saveSettings = function(socket, data, callback) { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketUser.setTopicSort = function(socket, sort, callback) { | SocketUser.setTopicSort = function(socket, sort, callback) { | ||||||
| 	if (socket.uid) { | 	if (!socket.uid) { | ||||||
| 		user.setSetting(socket.uid, 'topicPostSort', sort, callback); | 		return callback(); | ||||||
| 	} | 	} | ||||||
|  | 	user.setSetting(socket.uid, 'topicPostSort', sort, callback); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketUser.setCategorySort = function(socket, sort, callback) { | SocketUser.setCategorySort = function(socket, sort, callback) { | ||||||
| 	if (socket.uid) { | 	if (!socket.uid) { | ||||||
| 		user.setSetting(socket.uid, 'categoryTopicSort', sort, callback); | 		return callback(); | ||||||
| 	} | 	} | ||||||
|  | 	user.setSetting(socket.uid, 'categoryTopicSort', sort, callback); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| SocketUser.getUnreadCount = function(socket, data, callback) { | SocketUser.getUnreadCount = function(socket, data, callback) { | ||||||
|   | |||||||
| @@ -51,7 +51,7 @@ module.exports = function(SocketUser) { | |||||||
|  |  | ||||||
| 	SocketUser.uploadProfileImageFromUrl = function(socket, data, callback) { | 	SocketUser.uploadProfileImageFromUrl = function(socket, data, callback) { | ||||||
| 		if (!socket.uid || !data.url || !data.uid) { | 		if (!socket.uid || !data.url || !data.uid) { | ||||||
| 			return; | 			return callback(new Error('[[error:invalid-data]]')); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		user.isAdminOrSelf(socket.uid, data.uid, function(err) { | 		user.isAdminOrSelf(socket.uid, data.uid, function(err) { | ||||||
| @@ -66,7 +66,7 @@ module.exports = function(SocketUser) { | |||||||
|  |  | ||||||
| 	SocketUser.removeUploadedPicture = function(socket, data, callback) { | 	SocketUser.removeUploadedPicture = function(socket, data, callback) { | ||||||
| 		if (!socket.uid || !data.uid) { | 		if (!socket.uid || !data.uid) { | ||||||
| 			return; | 			return callback(new Error('[[error:invalid-data]]')); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		async.waterfall([ | 		async.waterfall([ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user