mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-28 02:09:52 +01:00
posts/categories.js
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var topics = require('../topics');
|
||||
var async = require('async'),
|
||||
topics = require('../topics');
|
||||
|
||||
module.exports = function(Posts) {
|
||||
|
||||
Posts.getCidByPid = function(pid, callback) {
|
||||
Posts.getPostField(pid, 'tid', function(err, tid) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
Posts.getPostField(pid, 'tid', next);
|
||||
},
|
||||
function(tid, next) {
|
||||
topics.getTopicField(tid, 'cid', next);
|
||||
},
|
||||
function(cid, next) {
|
||||
next(!cid ? new Error('[[error:invalid-cid]]') : null, cid);
|
||||
}
|
||||
|
||||
topics.getTopicField(tid, 'cid', function(err, cid) {
|
||||
if(err || !cid) {
|
||||
return callback(err || new Error('[[error:invalid-cid]]'));
|
||||
}
|
||||
callback(null, cid);
|
||||
});
|
||||
});
|
||||
], callback);
|
||||
};
|
||||
|
||||
Posts.getCidsByPids = function(pids, callback) {
|
||||
|
||||
Reference in New Issue
Block a user