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