mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
closes #1998
This commit is contained in:
@@ -102,7 +102,7 @@ var async = require('async'),
|
|||||||
return callback(null, []);
|
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);
|
db[reverse ? 'getSortedSetRevRange' : 'getSortedSetRange'](set, start, end, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Posts.getPostsByPids = function(pids, tid, callback) {
|
Posts.getPostsByPids = function(pids, callback) {
|
||||||
var keys = [];
|
var keys = [];
|
||||||
|
|
||||||
for(var x=0, numPids=pids.length; x<numPids; ++x) {
|
for(var x=0, numPids=pids.length; x<numPids; ++x) {
|
||||||
@@ -144,7 +144,7 @@ var async = require('async'),
|
|||||||
return callback(err);
|
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) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ var async = require('async'),
|
|||||||
if (!pids.length) {
|
if (!pids.length) {
|
||||||
return next(null, []);
|
return next(null, []);
|
||||||
}
|
}
|
||||||
posts.getPostsByPids(pids, tid, function(err, posts) {
|
posts.getPostsByPids(pids, function(err, posts) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ var async = require('async'),
|
|||||||
if (!parseInt(mainPid, 10)) {
|
if (!parseInt(mainPid, 10)) {
|
||||||
return callback(null, []);
|
return callback(null, []);
|
||||||
}
|
}
|
||||||
posts.getPostsByPids([mainPid], tid, function(err, postData) {
|
posts.getPostsByPids([mainPid], function(err, postData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(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) {
|
Topics.getTeasers = function(tids, uid, callback) {
|
||||||
if(!Array.isArray(tids)) {
|
if(!Array.isArray(tids)) {
|
||||||
return callback(null, []);
|
return callback(null, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user