Skip to content

Node.js based forum software built for the modern web

socket.io admin/groups

psychobunny5ffeb3319b26
diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js
index 70dfcffdb4..8b9adfb871 100644
--- a/src/socket.io/admin.js
+++ b/src/socket.io/admin.js
@@ -18,11 +18,11 @@ var groups = require('../groups'),
SocketAdmin = {
user: require('admin/user'),
categories: require('admin/categories'),
+ groups: require('admin/groups'),
themes: {},
plugins: {},
widgets: {},
config: {},
- groups: {},
settings: {}
};
@@ -67,7 +67,6 @@ SocketAdmin.fireEvent = function(socket, data, callback) {
index.server.sockets.emit(data.name, data.payload || {});
};
-
SocketAdmin.themes.getInstalled = function(socket, data, callback) {
meta.themes.get(callback);
};
@@ -100,7 +99,6 @@ SocketAdmin.widgets.set = function(socket, data, callback) {
widgets.setArea(data, callback);
};
-/* Configs */
SocketAdmin.config.get = function(socket, data, callback) {
meta.configs.list(callback);
};
@@ -130,56 +128,6 @@ SocketAdmin.config.remove = function(socket, 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) {
meta.settings.get(data.hash, callback);
};
diff --git a/src/socket.io/admin/groups.js b/src/socket.io/admin/groups.js
new file mode 100644
index 0000000000..c6254a2631
--- /dev/null
+++ b/src/socket.io/admin/groups.js
@@ -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;
\ No newline at end of file