diff --git a/public/src/forum/admin/groups.js b/public/src/forum/admin/groups.js index d6cf314171..078e3a4eab 100644 --- a/public/src/forum/admin/groups.js +++ b/public/src/forum/admin/groups.js @@ -29,7 +29,7 @@ define(function() { errorEl = $('#create-modal-error'), errorText; - socket.emit('api:groups.create', submitObj, function(err, data) { + socket.emit('api:admin.groups.create', submitObj, function(err, data) { if (err) { switch (err) { case 'group-exists': @@ -63,14 +63,14 @@ define(function() { case 'delete': bootbox.confirm('Are you sure you wish to delete this group?', function(confirm) { if (confirm) { - socket.emit('api:groups.delete', gid, function(err, data) { + socket.emit('api:admin.groups.delete', gid, function(err, data) { if (data === 'OK') ajaxify.go('admin/groups'); }); } }); break; case 'members': - socket.emit('api:groups.get', gid, function(err, groupObj) { + socket.emit('api:admin.groups.get', gid, function(err, groupObj) { var formEl = detailsModal.find('form'), nameEl = formEl.find('#change-group-name'), descEl = formEl.find('#change-group-desc'), @@ -152,7 +152,7 @@ define(function() { }); if (members.indexOf(uid) === -1) { - socket.emit('api:groups.join', { + socket.emit('api:admin.groups.join', { gid: gid, uid: uid }, function(err, data) { @@ -167,7 +167,7 @@ define(function() { var uid = this.getAttribute('data-uid'), gid = detailsModal.attr('data-gid'); - socket.emit('api:groups.leave', { + socket.emit('api:admin.groups.leave', { gid: gid, uid: uid }, function(err, data) { @@ -183,7 +183,7 @@ define(function() { descEl = formEl.find('#change-group-desc'), gid = detailsModal.attr('data-gid'); - socket.emit('api:groups.update', { + socket.emit('api:admin.groups.update', { gid: gid, values: { name: nameEl.val(), diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js index 6c4bc01f09..f95d03a571 100644 --- a/src/socket.io/admin.js +++ b/src/socket.io/admin.js @@ -275,4 +275,42 @@ SocketAdmin.config.remove = function(key) { meta.configs.remove(key); }; +/* Groups */ + +SocketAdmin.groups = {}; + +SocketAdmin.groups.create = function(data, callback) { + groups.create(data.name, data.description, function(err, groupObj) { + callback(err ? err.message : null, groupObj || undefined); + }); +}; + +SocketAdmin.groups.delete = function(gid, callback) { + groups.destroy(gid, function(err) { + callback(err ? err.message : null, err ? null : 'OK'); + }); +}; + +SocketAdmin.groups.get = function(gid, callback) { + groups.get(gid, { + expand: true + }, function(err, groupObj) { + callback(err ? err.message : null, groupObj || undefined); + }); +}; + +SocketAdmin.groups.join = function(data, callback) { + groups.join(data.gid, data.uid, callback); +}; + +SocketAdmin.groups.leave = function(data, callback) { + groups.leave(data.gid, data.uid, callback); +}; + +SocketAdmin.groups.update = function(data, callback) { + groups.update(data.gid, data.values, function(err) { + callback(err ? err.message : null); + }); +}; + module.exports = SocketAdmin; \ No newline at end of file diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js deleted file mode 100644 index fed37f76ac..0000000000 --- a/src/socket.io/groups.js +++ /dev/null @@ -1,39 +0,0 @@ -var groups = require('../groups'), - - SocketGroups = {}; - -SocketGroups.create = function(data, callback) { - groups.create(data.name, data.description, function(err, groupObj) { - callback(err ? err.message : null, groupObj || undefined); - }); -}; - -SocketGroups.delete = function(gid, callback) { - groups.destroy(gid, function(err) { - callback(err ? err.message : null, err ? null : 'OK'); - }); -}; - -SocketGroups.get = function(gid, callback) { - groups.get(gid, { - expand: true - }, function(err, groupObj) { - callback(err ? err.message : null, groupObj || undefined); - }); -}; - -SocketGroups.join = function(data, callback) { - groups.join(data.gid, data.uid, callback); -}; - -SocketGroups.leave = function(data, callback) { - groups.leave(data.gid, data.uid, callback); -}; - -SocketGroups.update = function(data, callback) { - groups.update(data.gid, data.values, function(err) { - callback(err ? err.message : null); - }); -}; - -module.exports = SocketGroups; \ No newline at end of file