mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 08:55:47 +01:00
closes #2480
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user