mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 05:55:48 +01:00
meta.configs tests
This commit is contained in:
@@ -37,16 +37,12 @@ var SocketAdmin = {
|
||||
};
|
||||
|
||||
SocketAdmin.before = function (socket, method, data, next) {
|
||||
if (!socket.uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.isAdministrator(socket.uid, function (err, isAdmin) {
|
||||
if (err || isAdmin) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
winston.warn('[socket.io] Call to admin method ( ' + method + ' ) blocked (accessed by uid ' + socket.uid + ')');
|
||||
next(new Error('[[error:no-privileges]]'));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -150,21 +146,9 @@ SocketAdmin.config.set = function (socket, data, callback) {
|
||||
if (!data) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
meta.configs.set(data.key, data.value, function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
callback();
|
||||
|
||||
plugins.fireHook('action:config.set', {
|
||||
key: data.key,
|
||||
value: data.value
|
||||
});
|
||||
|
||||
logger.monitorConfig({io: index.server}, data);
|
||||
});
|
||||
var _data = {};
|
||||
_data[data.key] = data.value;
|
||||
SocketAdmin.config.setMultiple(socket, data, callback);
|
||||
};
|
||||
|
||||
SocketAdmin.config.setMultiple = function (socket, data, callback) {
|
||||
@@ -172,29 +156,29 @@ SocketAdmin.config.setMultiple = function (socket, data, callback) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
meta.configs.setMultiple(data, function (err) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
callback();
|
||||
var setting;
|
||||
for(var field in data) {
|
||||
if (data.hasOwnProperty(field)) {
|
||||
setting = {
|
||||
key: field,
|
||||
value: data[field]
|
||||
};
|
||||
plugins.fireHook('action:config.set', setting);
|
||||
logger.monitorConfig({io: index.server}, setting);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
meta.configs.setMultiple(data, next);
|
||||
},
|
||||
function (next) {
|
||||
var setting;
|
||||
for (var field in data) {
|
||||
if (data.hasOwnProperty(field)) {
|
||||
setting = {
|
||||
key: field,
|
||||
value: data[field]
|
||||
};
|
||||
plugins.fireHook('action:config.set', setting);
|
||||
logger.monitorConfig({io: index.server}, setting);
|
||||
}
|
||||
}
|
||||
setImmediate(next);
|
||||
}
|
||||
});
|
||||
], callback);
|
||||
};
|
||||
|
||||
SocketAdmin.config.remove = function (socket, key, callback) {
|
||||
meta.configs.remove(key);
|
||||
callback();
|
||||
meta.configs.remove(key, callback);
|
||||
};
|
||||
|
||||
SocketAdmin.settings.get = function (socket, data, callback) {
|
||||
|
||||
Reference in New Issue
Block a user