no need for exists check

if topic doesnt exist topicData will be null
v1.18.x
barisusakli 11 years ago
parent a695c6134b
commit ca0dbf84be

@ -272,28 +272,25 @@ var async = require('async'),
}; };
Topics.getTopicWithPosts = function(tid, uid, start, end, callback) { Topics.getTopicWithPosts = function(tid, uid, start, end, callback) {
threadTools.exists(tid, function(err, exists) { Topics.getTopicData(tid, function(err, topicData) {
if (err || !exists) { if (err || !topicData) {
return callback(err || new Error('Topic tid \'' + tid + '\' not found')); return callback(err || new Error('Topic tid \'' + tid + '\' not found'));
} }
async.parallel({ async.parallel({
topicData : function(next) { posts: function(next) {
Topics.getTopicData(tid, next);
},
posts : function(next) {
Topics.getTopicPosts(tid, start, end, uid, false, next); Topics.getTopicPosts(tid, start, end, uid, false, next);
}, },
privileges : function(next) { privileges: function(next) {
threadTools.privileges(tid, uid, next); threadTools.privileges(tid, uid, next);
}, },
category : function(next) { category: function(next) {
Topics.getCategoryData(tid, next); Topics.getCategoryData(tid, next);
}, },
pageCount : function(next) { pageCount: function(next) {
Topics.getPageCount(tid, uid, next); Topics.getPageCount(tid, uid, next);
}, },
threadTools : function(next) { threadTools: function(next) {
plugins.fireHook('filter:topic.thread_tools', [], next); plugins.fireHook('filter:topic.thread_tools', [], next);
} }
}, function(err, results) { }, function(err, results) {
@ -301,7 +298,6 @@ var async = require('async'),
return callback(err); return callback(err);
} }
var topicData = results.topicData;
topicData.category = results.category; topicData.category = results.category;
topicData.posts = results.posts; topicData.posts = results.posts;
topicData.thread_tools = results.threadTools; topicData.thread_tools = results.threadTools;

@ -2,15 +2,12 @@
'use strict'; 'use strict';
var async = require('async'), var async = require('async'),
db = require('./../database'), db = require('./../database'),
utils = require('./../../public/src/utils'), utils = require('./../../public/src/utils'),
plugins = require('./../plugins'), plugins = require('./../plugins'),
user = require('./../user'), user = require('./../user'),
meta = require('./../meta'), meta = require('./../meta'),
posts = require('./../posts'), posts = require('./../posts'),
threadTools = require('./../threadTools'), threadTools = require('./../threadTools'),
categoryTools = require('./../categoryTools'); categoryTools = require('./../categoryTools');

Loading…
Cancel
Save