-
+
@@ -79,7 +79,8 @@
diff --git a/src/groups.js b/src/groups.js
index 0cb4495f35..144cf98f4f 100644
--- a/src/groups.js
+++ b/src/groups.js
@@ -76,6 +76,12 @@ var async = require('async'),
} else callback(new Error('group-exists'))
});
},
+ update: function(gid, values, callback) {
+ RDB.exists('gid:' + gid, function(err, exists) {
+ if (!err && exists) RDB.hmset('gid:' + gid, values, callback);
+ else calback(new Error('gid-not-found'));
+ });
+ },
destroy: function(gid, callback) {
RDB.hset('gid:' + gid, 'deleted', '1', callback);
},
diff --git a/src/websockets.js b/src/websockets.js
index 204330b356..0dbf3e5f32 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -822,6 +822,20 @@ var SocketIO = require('socket.io').listen(global.server, {
callback(err ? err.message : null, groupObj || undefined);
});
});
+
+ socket.on('api:groups.join', function(data, callback) {
+ Groups.join(data.gid, data.uid, callback);
+ });
+
+ socket.on('api:groups.leave', function(data, callback) {
+ Groups.leave(data.gid, data.uid, callback);
+ });
+
+ socket.on('api:groups.update', function(data, callback) {
+ Groups.update(data.gid, data.values, function(err) {
+ callback(err ? err.message : null);
+ });
+ });
});
}(SocketIO));