mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
resolved #868
This commit is contained in:
@@ -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) {
|
||||
db.getObjectField('gid:' + gid, 'deleted', function(err, deleted) {
|
||||
callback(err, parseInt(deleted, 10) === 1);
|
||||
|
||||
11
src/socket.io/groups.js
Normal file
11
src/socket.io/groups.js
Normal 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;
|
||||
Reference in New Issue
Block a user