v1.18.x
barisusakli 11 years ago
parent 77a7c5caef
commit b858b120da

@ -102,7 +102,7 @@ var async = require('async'),
return callback(null, []);
}
Posts.getPostsByPids(pids, tid, callback);
Posts.getPostsByPids(pids, callback);
});
};
@ -110,7 +110,7 @@ var async = require('async'),
db[reverse ? 'getSortedSetRevRange' : 'getSortedSetRange'](set, start, end, callback);
};
Posts.getPostsByPids = function(pids, tid, callback) {
Posts.getPostsByPids = function(pids, callback) {
var keys = [];
for(var x=0, numPids=pids.length; x<numPids; ++x) {
@ -144,7 +144,7 @@ var async = require('async'),
return callback(err);
}
plugins.fireHook('filter:post.getPosts', {tid: tid, posts: posts}, function(err, data) {
plugins.fireHook('filter:post.getPosts', {posts: posts}, function(err, data) {
if (err) {
return callback(err);
}

@ -266,7 +266,7 @@ var async = require('async'),
if (!pids.length) {
return next(null, []);
}
posts.getPostsByPids(pids, tid, function(err, posts) {
posts.getPostsByPids(pids, function(err, posts) {
if (err) {
return next(err);
}
@ -315,7 +315,7 @@ var async = require('async'),
if (!parseInt(mainPid, 10)) {
return callback(null, []);
}
posts.getPostsByPids([mainPid], tid, function(err, postData) {
posts.getPostsByPids([mainPid], function(err, postData) {
if (err) {
return callback(err);
}
@ -328,6 +328,34 @@ var async = require('async'),
});
};
Topics.getMainPosts = function(tids, uid, callback) {
var keys = tids.map(function(tid) {
return 'topic:' + tid;
});
db.getObjectsFields(keys, ['mainPid'], function(err, topicData) {
if (err) {
return callback(err);
}
var mainPids = topicData.map(function(topic) {
return topic ? topic.mainPid : null;
});
posts.getPostsByPids(mainPids, function(err, postData) {
if (err) {
return callback(err);
}
if (!Array.isArray(postData) || !postData.length) {
return callback(null, []);
}
Topics.addPostData(postData, uid, callback);
});
});
}
Topics.getTeasers = function(tids, uid, callback) {
if(!Array.isArray(tids)) {
return callback(null, []);

Loading…
Cancel
Save