Merge remote-tracking branch 'origin/master' into socket.io1.x

v1.18.x
barisusakli 10 years ago
commit 7f81a0b0ad

@ -8,6 +8,7 @@ var async = require('async'),
db = require('./database'),
plugins = require('./plugins'),
posts = require('./posts'),
privileges = require('./privileges'),
utils = require('../public/src/utils');
@ -525,23 +526,26 @@ var async = require('async'),
};
Groups.getLatestMemberPosts = function(groupName, max, uid, callback) {
Groups.get(groupName, {}, function(err, groupObj) {
if (err || parseInt(groupObj.memberCount, 10) === 0) {
return callback(null, []);
}
var keys = groupObj.members.map(function(uid) {
return 'uid:' + uid + ':posts';
});
db.getSortedSetRevUnion(keys, 0, max-1, function(err, pids) {
if (err) {
return callback(err);
async.waterfall([
function(next) {
Groups.getMembers(groupName, next);
},
function(uids, next) {
if (!Array.isArray(uids) || !uids.length) {
return callback(null, []);
}
posts.getPostSummaryByPids(pids, uid, {stripTags: false}, callback);
});
});
var keys = uids.map(function(uid) {
return 'uid:' + uid + ':posts';
});
db.getSortedSetRevUnion(keys, 0, max - 1, next);
},
function(pids, next) {
privileges.posts.filter('read', pids, uid, next);
},
function(pids, next) {
posts.getPostSummaryByPids(pids, uid, {stripTags: false}, next);
}
], callback);
};
Groups.getUserGroups = function(uids, callback) {

Loading…
Cancel
Save