mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
assorted config fixes
This commit is contained in:
1
app.js
1
app.js
@@ -16,7 +16,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Read config.js to grab redis info
|
||||
var fs = require('fs'),
|
||||
nconf = require('nconf'),
|
||||
pkg = require('./package.json'),
|
||||
|
||||
@@ -299,22 +299,22 @@ define(['taskbar'], function(taskbar) {
|
||||
titleEl.value = titleEl.value.trim();
|
||||
bodyEl.value = bodyEl.value.trim();
|
||||
|
||||
if (titleEl.value.length < 3) {
|
||||
if (titleEl.value.length < config.minimumTitleLength) {
|
||||
return app.alert({
|
||||
type: 'error',
|
||||
timeout: 2000,
|
||||
title: 'Title too short',
|
||||
message: "Please enter a longer title. At least 3 characters.",
|
||||
message: "Please enter a longer title. At least " + config.minimumTitleLength+ " characters.",
|
||||
alert_id: 'post_error'
|
||||
});
|
||||
}
|
||||
|
||||
if (bodyEl.value.length < 8) {
|
||||
if (bodyEl.value.length < config.minimumPostLength) {
|
||||
return app.alert({
|
||||
type: 'error',
|
||||
timeout: 2000,
|
||||
title: 'Content too short',
|
||||
message: "Please enter a longer post. At least 8 characters.",
|
||||
message: "Please enter a longer post. At least " + config.minimumPostLength + " characters.",
|
||||
alert_id: 'post_error'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -78,12 +78,15 @@ var async = require('async'),
|
||||
port: config.port
|
||||
},
|
||||
api_url: protocol + '//' + host + (config.use_port ? ':' + config.port : '') + relative_path + '/api/',
|
||||
relative_path: relative_path
|
||||
relative_path: relative_path,
|
||||
minimumTitleLength: 3,
|
||||
minimumPostLength: 8
|
||||
};
|
||||
|
||||
server_conf.base_url = protocol + '//' + host;
|
||||
server_conf.relative_path = relative_path;
|
||||
server_conf.imgurClientID = '';
|
||||
server_conf.post_delay = 10000;
|
||||
|
||||
install.save(server_conf, client_conf, callback);
|
||||
});
|
||||
|
||||
11
src/posts.js
11
src/posts.js
@@ -10,12 +10,12 @@ var RDB = require('./redis.js'),
|
||||
async = require('async'),
|
||||
plugins = require('./plugins'),
|
||||
reds = require('reds'),
|
||||
nconf = require('nconf'),
|
||||
clientConfig = require('../public/config.json'),
|
||||
postSearch = reds.createSearch('nodebbpostsearch');
|
||||
|
||||
(function(Posts) {
|
||||
|
||||
Posts.minimumPostLength = 8;
|
||||
|
||||
Posts.getPostsByTid = function(tid, start, end, callback) {
|
||||
RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) {
|
||||
|
||||
@@ -182,7 +182,7 @@ var RDB = require('./redis.js'),
|
||||
Posts.emitTooManyPostsAlert = function(socket) {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Too many posts!',
|
||||
message: 'You can only post every '+ (config.post_delay / 1000) + ' seconds.',
|
||||
message: 'You can only post every '+ (nconf.get('post_delay') / 1000) + ' seconds.',
|
||||
type: 'error',
|
||||
timeout: 2000
|
||||
});
|
||||
@@ -193,14 +193,13 @@ var RDB = require('./redis.js'),
|
||||
content = content.trim();
|
||||
}
|
||||
|
||||
if (!content || content.length < Posts.minimumPostLength) {
|
||||
if (!content || content.length < clientConfig.minimumPostLength) {
|
||||
callback(new Error('content-too-short'), null);
|
||||
return;
|
||||
}
|
||||
|
||||
user.getUserField(uid, 'lastposttime', function(lastposttime) {
|
||||
|
||||
if(Date.now() - lastposttime < config.post_delay) {
|
||||
if(Date.now() - lastposttime < nconf.get('post_delay')) {
|
||||
callback(new Error('too-many-posts'), null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ var RDB = require('./redis.js')
|
||||
async = require('async'),
|
||||
feed = require('./feed.js'),
|
||||
favourites = require('./favourites.js'),
|
||||
clientConfig = require('../public/config.json'),
|
||||
reds = require('reds'),
|
||||
topicSearch = reds.createSearch('nodebbtopicsearch');
|
||||
|
||||
@@ -20,7 +21,7 @@ marked.setOptions({
|
||||
|
||||
(function(Topics) {
|
||||
|
||||
Topics.minimumTitleLength = 3;
|
||||
|
||||
|
||||
Topics.getTopicData = function(tid, callback) {
|
||||
RDB.hgetall('topic:' + tid, function(err, data) {
|
||||
@@ -530,7 +531,7 @@ marked.setOptions({
|
||||
type: 'error',
|
||||
timeout: 2000,
|
||||
title: 'Title too short',
|
||||
message: "Please enter a longer title. At least " + Topics.minimumTitleLength + " characters.",
|
||||
message: "Please enter a longer title. At least " + clientConfig.minimumTitleLength + " characters.",
|
||||
alert_id: 'post_error'
|
||||
});
|
||||
}
|
||||
@@ -547,17 +548,17 @@ marked.setOptions({
|
||||
if (uid === 0) {
|
||||
callback(new Error('not-logged-in'), null);
|
||||
return;
|
||||
} else if(!title || title.length < Topics.minimumTitleLength) {
|
||||
} else if(!title || title.length < clientConfig.minimumTitleLength) {
|
||||
callback(new Error('title-too-short'), null);
|
||||
return;
|
||||
} else if (!content || content.length < posts.miminumPostLength) {
|
||||
} else if (!content || content.length < clientConfig.miminumPostLength) {
|
||||
callback(new Error('content-too-short'), null);
|
||||
return;
|
||||
}
|
||||
|
||||
user.getUserField(uid, 'lastposttime', function(lastposttime) {
|
||||
|
||||
if(Date.now() - lastposttime < config.post_delay) {
|
||||
if(Date.now() - lastposttime < nconf.get('post_delay')) {
|
||||
callback(new Error('too-many-posts'), null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
if(err) {
|
||||
if(err.message === 'content-too-short') {
|
||||
posts.emitContentTooShortAlert(socket);
|
||||
} else if(err.messages === 'too-many-posts') {
|
||||
} else if(err.message === 'too-many-posts') {
|
||||
posts.emitTooManyPostsAlert(socket);
|
||||
} else if(err.message === 'reply-error') {
|
||||
socket.emit('event:alert', {
|
||||
@@ -462,7 +462,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
if(!data.title || data.title.length < topics.minimumTitleLength) {
|
||||
topics.emitTitleTooShortAlert(socket);
|
||||
return;
|
||||
} else if (!data.content || data.content.length < posts.minimumPostLength) {
|
||||
} else if (!data.content || data.content.length < require('../public/config.json').minimumPostLength) {
|
||||
posts.emitContentTooShortAlert(socket);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user