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

44 lines
963 B
JavaScript

10 years ago
'use strict';
var async = require('async'),
topics = require('../topics');
module.exports = function(Posts) {
Posts.getPostsByTid = function(tid, set, start, stop, uid, reverse, callback) {
Posts.getPidsFromSet(set, start, stop, reverse, function(err, pids) {
10 years ago
if (err) {
return callback(err);
}
if (!Array.isArray(pids) || !pids.length) {
return callback(null, []);
}
Posts.getPostsByPids(pids, uid, callback);
});
};
Posts.isMain = function(pid, callback) {
Posts.getPostField(pid, 'tid', function(err, tid) {
if (err) {
return callback(err);
}
topics.getTopicField(tid, 'mainPid', function(err, mainPid) {
callback(err, parseInt(pid, 10) === parseInt(mainPid, 10));
});
});
};
Posts.getTopicFields = function(pid, fields, callback) {
Posts.getPostField(pid, 'tid', function(err, tid) {
if (err) {
return callback(err);
}
topics.getTopicFields(tid, fields, callback);
});
};
};