mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-13 01:15:47 +01:00
topic exists checks
This commit is contained in:
@@ -26,6 +26,12 @@ module.exports = function(Topics) {
|
|||||||
var topicData;
|
var topicData;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
|
Topics.exists(tid, next);
|
||||||
|
},
|
||||||
|
function (exists, next) {
|
||||||
|
if (!exists) {
|
||||||
|
return next(new Error('[[error:no-topic]]'));
|
||||||
|
}
|
||||||
privileges.topics.isOwnerOrAdminOrMod(tid, uid, next);
|
privileges.topics.isOwnerOrAdminOrMod(tid, uid, next);
|
||||||
},
|
},
|
||||||
function (isOwnerOrAdminOrMod, next) {
|
function (isOwnerOrAdminOrMod, next) {
|
||||||
@@ -158,7 +164,7 @@ module.exports = function(Topics) {
|
|||||||
},
|
},
|
||||||
function (exists, next) {
|
function (exists, next) {
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
return callback();
|
return callback(new Error('[[error:no-topic]]'));
|
||||||
}
|
}
|
||||||
Topics.getTopicFields(tid, ['cid', 'lastposttime'], next);
|
Topics.getTopicFields(tid, ['cid', 'lastposttime'], next);
|
||||||
},
|
},
|
||||||
@@ -194,6 +200,12 @@ module.exports = function(Topics) {
|
|||||||
var topic;
|
var topic;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
|
Topics.exists(tid, next);
|
||||||
|
},
|
||||||
|
function (exists, next) {
|
||||||
|
if (!exists) {
|
||||||
|
return next(new Error('[[error:no-topic]]'));
|
||||||
|
}
|
||||||
Topics.getTopicFields(tid, ['cid', 'lastposttime', 'pinned', 'deleted', 'postcount'], next);
|
Topics.getTopicFields(tid, ['cid', 'lastposttime', 'pinned', 'deleted', 'postcount'], next);
|
||||||
},
|
},
|
||||||
function (topicData, next) {
|
function (topicData, next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user