You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/src/posts/topics.js

45 lines
963 B
JavaScript

'use strict';
var async = require('async'),
topics = require('../topics');
module.exports = function(Posts) {
Posts.getPostsFromSet = function(set, start, stop, uid, reverse, callback) {
async.waterfall([
function(next) {
Posts.getPidsFromSet(set, start, stop, reverse, next);
},
function(pids, next) {
Posts.getPostsByPids(pids, uid, next);
}
], callback);
};
Posts.isMain = function(pid, callback) {
async.waterfall([
function(next) {
Posts.getPostField(pid, 'tid', next);
},
function(tid, next) {
topics.getTopicField(tid, 'mainPid', next);
},
function(mainPid, next) {
next(null, parseInt(pid, 10) === parseInt(mainPid, 10));
}
], callback);
};
Posts.getTopicFields = function(pid, fields, callback) {
async.waterfall([
function(next) {
Posts.getPostField(pid, 'tid', next);
},
function(tid, next) {
topics.getTopicFields(tid, fields, next);
}
], callback);
};
};