|
|
@ -144,6 +144,14 @@ var async = require('async'),
|
|
|
|
next(null, isMember);
|
|
|
|
next(null, isMember);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
isPending: function(next) {
|
|
|
|
|
|
|
|
// Retrieve group membership state, if uid is passed in
|
|
|
|
|
|
|
|
if (!options.uid) {
|
|
|
|
|
|
|
|
return next();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.isSetMember('group:' + groupName + ':pending', options.uid, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
isOwner: function(next) {
|
|
|
|
isOwner: function(next) {
|
|
|
|
// Retrieve group ownership state, if uid is passed in
|
|
|
|
// Retrieve group ownership state, if uid is passed in
|
|
|
|
if (!options.uid) {
|
|
|
|
if (!options.uid) {
|
|
|
@ -173,12 +181,19 @@ var async = require('async'),
|
|
|
|
results.base.deletable = !results.base.system;
|
|
|
|
results.base.deletable = !results.base.system;
|
|
|
|
results.base.truncated = truncated;
|
|
|
|
results.base.truncated = truncated;
|
|
|
|
results.base.isMember = results.isMember;
|
|
|
|
results.base.isMember = results.isMember;
|
|
|
|
|
|
|
|
results.base.isPending = results.isPending;
|
|
|
|
results.base.isOwner = results.isOwner;
|
|
|
|
results.base.isOwner = results.isOwner;
|
|
|
|
|
|
|
|
|
|
|
|
callback(err, results.base);
|
|
|
|
callback(err, results.base);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Groups.isPrivate = function(groupName, callback) {
|
|
|
|
|
|
|
|
db.getObjectField('group:' + groupName, 'private', function(err, isPrivate) {
|
|
|
|
|
|
|
|
callback(err, isPrivate || isPrivate === null); // Private, if not set at all
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Groups.getMembers = function(groupName, callback) {
|
|
|
|
Groups.getMembers = function(groupName, callback) {
|
|
|
|
db.getSetMembers('group:' + groupName + ':members', callback);
|
|
|
|
db.getSetMembers('group:' + groupName + ':members', callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -521,6 +536,20 @@ var async = require('async'),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Groups.requestMembership = function(groupName, uid, callback) {
|
|
|
|
|
|
|
|
db.setAdd('group:' + groupName + ':pending', uid, callback);
|
|
|
|
|
|
|
|
plugins.fireHook('action:groups.requestMembership', {
|
|
|
|
|
|
|
|
groupName: groupName,
|
|
|
|
|
|
|
|
uid: uid
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Groups.approveMembership = function(groupName, uid, callback) {
|
|
|
|
|
|
|
|
// Note: For simplicity, this method intentially doesn't check the caller uid for ownership!
|
|
|
|
|
|
|
|
db.setRemove('group:' + groupName + ':pending', uid, callback);
|
|
|
|
|
|
|
|
Groups.join.apply(Groups, arguments);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Groups.leave = function(groupName, uid, callback) {
|
|
|
|
Groups.leave = function(groupName, uid, callback) {
|
|
|
|
callback = callback || function() {};
|
|
|
|
callback = callback || function() {};
|
|
|
|
|
|
|
|
|
|
|
|