mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	removed socket emits for post errors
This commit is contained in:
		| @@ -314,37 +314,9 @@ function emitOnlineUserCount(callback) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| Sockets.emitAlert = emitAlert; |  | ||||||
| function emitAlert(socket, title, message) { |  | ||||||
| 	socket.emit('event:alert', { |  | ||||||
| 		type: 'danger', |  | ||||||
| 		timeout: 2000, |  | ||||||
| 		title: title, |  | ||||||
| 		message: message, |  | ||||||
| 		alert_id: 'post_error' |  | ||||||
| 	}); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| Sockets.emitContentTooShortAlert = emitContentTooShortAlert; |  | ||||||
| function emitContentTooShortAlert(socket) { |  | ||||||
| 	socket.emit('event:alert', { |  | ||||||
| 		type: 'danger', |  | ||||||
| 		timeout: 2000, |  | ||||||
| 		title: 'Content too short', |  | ||||||
| 		message: "Please enter a longer post. At least " + meta.config.minimumPostLength + " characters.", |  | ||||||
| 		alert_id: 'post_error' |  | ||||||
| 	}); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| Sockets.emitTooManyPostsAlert = emitTooManyPostsAlert; |  | ||||||
| function emitTooManyPostsAlert(socket) { |  | ||||||
| 	socket.emit('event:alert', { |  | ||||||
| 		title: 'Too many posts!', |  | ||||||
| 		message: 'You can only post every ' + meta.config.postDelay + ' seconds.', |  | ||||||
| 		type: 'danger', |  | ||||||
| 		timeout: 2000 |  | ||||||
| 	}); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /* Exporting */ | /* Exporting */ | ||||||
| module.exports = Sockets; | module.exports = Sockets; | ||||||
| @@ -126,21 +126,13 @@ SocketPosts.getRawPost = function(socket, pid, callback) { | |||||||
|  |  | ||||||
| SocketPosts.edit = function(socket, data, callback) { | SocketPosts.edit = function(socket, data, callback) { | ||||||
| 	if(!socket.uid) { | 	if(!socket.uid) { | ||||||
| 		socket.emit('event:alert', { | 		return callback(new Error('[[error:not-logged-in]]')); | ||||||
| 			title: 'Can't edit', |  | ||||||
| 			message: 'Guests can't edit posts!', |  | ||||||
| 			type: 'warning', |  | ||||||
| 			timeout: 2000 |  | ||||||
| 		}); |  | ||||||
| 		return callback(new Error('not-logged-in')); |  | ||||||
| 	} else if(!data || !data.pid || !data.title || !data.content) { | 	} else if(!data || !data.pid || !data.title || !data.content) { | ||||||
| 		return callback(new Error('invalid data')); | 		return callback(new Error('[[error:invalid-data]]')); | ||||||
| 	} else if (!data.title || data.title.length < parseInt(meta.config.minimumTitleLength, 10)) { | 	} else if (!data.title || data.title.length < parseInt(meta.config.minimumTitleLength, 10)) { | ||||||
| 		topics.emitTitleTooShortAlert(socket); | 		return callback(new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]')); | ||||||
| 		return callback(new Error('title-too-short')); |  | ||||||
| 	} else if (!data.content || data.content.length < parseInt(meta.config.minimumPostLength, 10)) { | 	} else if (!data.content || data.content.length < parseInt(meta.config.minimumPostLength, 10)) { | ||||||
| 		module.parent.exports.emitContentTooShortAlert(socket); | 		return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]')); | ||||||
| 		return callback(new Error('content-too-short')); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	postTools.edit(socket.uid, data.pid, data.title, data.content, {topic_thumb: data.topic_thumb}, function(err, results) { | 	postTools.edit(socket.uid, data.pid, data.title, data.content, {topic_thumb: data.topic_thumb}, function(err, results) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user