mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
closes #2396
This commit is contained in:
@@ -69,7 +69,7 @@ var async = require('async'),
|
|||||||
return callback(null, 1);
|
return callback(null, 1);
|
||||||
}
|
}
|
||||||
user.getSettings(uid, function(err, settings) {
|
user.getSettings(uid, function(err, settings) {
|
||||||
if(err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,11 +103,14 @@ module.exports = function(Topics) {
|
|||||||
|
|
||||||
if (!title || title.length < parseInt(meta.config.minimumTitleLength, 10)) {
|
if (!title || title.length < parseInt(meta.config.minimumTitleLength, 10)) {
|
||||||
return callback(new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]'));
|
return callback(new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]'));
|
||||||
} else if(title.length > parseInt(meta.config.maximumTitleLength, 10)) {
|
} else if (title.length > parseInt(meta.config.maximumTitleLength, 10)) {
|
||||||
return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]'));
|
return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
|
function(next) {
|
||||||
|
checkContentLength(content, next);
|
||||||
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
categories.exists(cid, next);
|
categories.exists(cid, next);
|
||||||
},
|
},
|
||||||
@@ -220,11 +223,10 @@ module.exports = function(Topics) {
|
|||||||
content = content.trim();
|
content = content.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!content || content.length < parseInt(meta.config.miminumPostLength, 10)) {
|
checkContentLength(content, next);
|
||||||
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
|
},
|
||||||
}
|
function(next) {
|
||||||
|
posts.create({uid: uid, tid: tid, content: content, toPid: toPid}, next);
|
||||||
posts.create({uid:uid, tid:tid, content:content, toPid:toPid}, next);
|
|
||||||
},
|
},
|
||||||
function(data, next) {
|
function(data, next) {
|
||||||
postData = data;
|
postData = data;
|
||||||
@@ -277,4 +279,11 @@ module.exports = function(Topics) {
|
|||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function checkContentLength(content, callback) {
|
||||||
|
if (!content || content.length < parseInt(meta.config.miminumPostLength, 10)) {
|
||||||
|
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user