diff --git a/src/socket.io/posts/edit.js b/src/socket.io/posts/edit.js index 1e41c4ab61..5ab6973ce1 100644 --- a/src/socket.io/posts/edit.js +++ b/src/socket.io/posts/edit.js @@ -13,14 +13,16 @@ var websockets = require('../index'); module.exports = function (SocketPosts) { SocketPosts.edit = function (socket, data, callback) { - // Trim and remove HTML (latter for composers that send in HTML, like redactor) - var contentLen = S(data.content).stripTags().s.trim().length; - if (!socket.uid) { return callback(new Error('[[error:not-logged-in]]')); } else if (!data || !data.pid || !data.content) { return callback(new Error('[[error:invalid-data]]')); - } else if (data.title && data.title.length < parseInt(meta.config.minimumTitleLength, 10)) { + } + + // Trim and remove HTML (latter for composers that send in HTML, like redactor) + var contentLen = S(data.content).stripTags().s.trim().length; + + if (data.title && data.title.length < parseInt(meta.config.minimumTitleLength, 10)) { return callback(new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]')); } else if (data.title && data.title.length > parseInt(meta.config.maximumTitleLength, 10)) { return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]')); @@ -28,7 +30,7 @@ module.exports = function (SocketPosts) { return callback(new Error('[[error:not-enough-tags, ' + meta.config.minimumTagsPerTopic + ']]')); } else if (data.tags && data.tags.length > parseInt(meta.config.maximumTagsPerTopic, 10)) { return callback(new Error('[[error:too-many-tags, ' + meta.config.maximumTagsPerTopic + ']]')); - } else if (!data.content || contentLen < parseInt(meta.config.minimumPostLength, 10)) { + } else if (contentLen < parseInt(meta.config.minimumPostLength, 10)) { return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]')); } else if (contentLen > parseInt(meta.config.maximumPostLength, 10)) { return callback(new Error('[[error:content-too-long, ' + meta.config.maximumPostLength + ']]'));