mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
socket.io admin/groups
This commit is contained in:
@@ -18,11 +18,11 @@ var groups = require('../groups'),
|
|||||||
SocketAdmin = {
|
SocketAdmin = {
|
||||||
user: require('admin/user'),
|
user: require('admin/user'),
|
||||||
categories: require('admin/categories'),
|
categories: require('admin/categories'),
|
||||||
|
groups: require('admin/groups'),
|
||||||
themes: {},
|
themes: {},
|
||||||
plugins: {},
|
plugins: {},
|
||||||
widgets: {},
|
widgets: {},
|
||||||
config: {},
|
config: {},
|
||||||
groups: {},
|
|
||||||
settings: {}
|
settings: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -67,7 +67,6 @@ SocketAdmin.fireEvent = function(socket, data, callback) {
|
|||||||
index.server.sockets.emit(data.name, data.payload || {});
|
index.server.sockets.emit(data.name, data.payload || {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SocketAdmin.themes.getInstalled = function(socket, data, callback) {
|
SocketAdmin.themes.getInstalled = function(socket, data, callback) {
|
||||||
meta.themes.get(callback);
|
meta.themes.get(callback);
|
||||||
};
|
};
|
||||||
@@ -100,7 +99,6 @@ SocketAdmin.widgets.set = function(socket, data, callback) {
|
|||||||
widgets.setArea(data, callback);
|
widgets.setArea(data, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Configs */
|
|
||||||
SocketAdmin.config.get = function(socket, data, callback) {
|
SocketAdmin.config.get = function(socket, data, callback) {
|
||||||
meta.configs.list(callback);
|
meta.configs.list(callback);
|
||||||
};
|
};
|
||||||
@@ -130,56 +128,6 @@ SocketAdmin.config.remove = function(socket, key) {
|
|||||||
meta.configs.remove(key);
|
meta.configs.remove(key);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Groups */
|
|
||||||
SocketAdmin.groups.create = function(socket, data, callback) {
|
|
||||||
if(!data) {
|
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
groups.create(data.name, data.description, function(err, groupObj) {
|
|
||||||
callback(err, groupObj || undefined);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
SocketAdmin.groups.delete = function(socket, groupName, callback) {
|
|
||||||
groups.destroy(groupName, callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
SocketAdmin.groups.get = function(socket, groupName, callback) {
|
|
||||||
groups.get(groupName, {
|
|
||||||
expand: true
|
|
||||||
}, function(err, groupObj) {
|
|
||||||
callback(err, groupObj || undefined);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
SocketAdmin.groups.join = function(socket, data, callback) {
|
|
||||||
if(!data) {
|
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
groups.join(data.groupName, data.uid, callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
SocketAdmin.groups.leave = function(socket, data, callback) {
|
|
||||||
if(!data) {
|
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
groups.leave(data.groupName, data.uid, callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
SocketAdmin.groups.update = function(socket, data, callback) {
|
|
||||||
if(!data) {
|
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
groups.update(data.groupName, data.values, function(err) {
|
|
||||||
callback(err ? err.message : null);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Settings */
|
|
||||||
SocketAdmin.settings.get = function(socket, data, callback) {
|
SocketAdmin.settings.get = function(socket, data, callback) {
|
||||||
meta.settings.get(data.hash, callback);
|
meta.settings.get(data.hash, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
54
src/socket.io/admin/groups.js
Normal file
54
src/socket.io/admin/groups.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
var groups = require('../../groups'),
|
||||||
|
Groups = {};
|
||||||
|
|
||||||
|
Groups.create = function(socket, data, callback) {
|
||||||
|
if(!data) {
|
||||||
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
|
}
|
||||||
|
|
||||||
|
groups.create(data.name, data.description, function(err, groupObj) {
|
||||||
|
callback(err, groupObj || undefined);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Groups.delete = function(socket, groupName, callback) {
|
||||||
|
groups.destroy(groupName, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
Groups.get = function(socket, groupName, callback) {
|
||||||
|
groups.get(groupName, {
|
||||||
|
expand: true
|
||||||
|
}, function(err, groupObj) {
|
||||||
|
callback(err, groupObj || undefined);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Groups.join = function(socket, data, callback) {
|
||||||
|
if(!data) {
|
||||||
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
|
}
|
||||||
|
|
||||||
|
groups.join(data.groupName, data.uid, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
Groups.leave = function(socket, data, callback) {
|
||||||
|
if(!data) {
|
||||||
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
|
}
|
||||||
|
|
||||||
|
groups.leave(data.groupName, data.uid, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
Groups.update = function(socket, data, callback) {
|
||||||
|
if(!data) {
|
||||||
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
|
}
|
||||||
|
|
||||||
|
groups.update(data.groupName, data.values, function(err) {
|
||||||
|
callback(err ? err.message : null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = Groups;
|
||||||
Reference in New Issue
Block a user