This commit is contained in:
Julian Lam
2014-02-06 17:09:36 -05:00
parent 4e776cad96
commit d360a9bcac
2 changed files with 29 additions and 0 deletions

View File

@@ -86,6 +86,24 @@
}); });
}; };
Groups.getMemberships = function(uid, callback) {
if (!uid) {
return callback(new Error('no-uid-specified'));
}
db.getObjectValues('group:gid', function(err, gids) {
async.filter(gids, function(gid, next) {
Groups.isMember(uid, gid, function(err, isMember) {
next(isMember);
});
}, function(gids) {
async.map(gids, function(gid, next) {
Groups.get(gid, {}, next);
}, callback);
});
});
};
Groups.isDeleted = function(gid, callback) { Groups.isDeleted = function(gid, callback) {
db.getObjectField('gid:' + gid, 'deleted', function(err, deleted) { db.getObjectField('gid:' + gid, 'deleted', function(err, deleted) {
callback(err, parseInt(deleted, 10) === 1); callback(err, parseInt(deleted, 10) === 1);

11
src/socket.io/groups.js Normal file
View File

@@ -0,0 +1,11 @@
var Groups = require('../groups'),
SocketGroups = {};
SocketGroups.getMemberships = function(socket, data, callback) {
if (data && data.uid) {
Groups.getMemberships(data.uid, callback);
}
};
module.exports = SocketGroups;