v1.18.x
barisusakli 10 years ago
parent f531a5362d
commit 51c520f888

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

Loading…
Cancel
Save