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