Merge branch 'master' into develop

v1.18.x
Julian Lam 8 years ago
commit db0a42d808

@ -13,14 +13,16 @@ var websockets = require('../index');
module.exports = function (SocketPosts) { module.exports = function (SocketPosts) {
SocketPosts.edit = function (socket, data, callback) { 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) { if (!socket.uid) {
return callback(new Error('[[error:not-logged-in]]')); return callback(new Error('[[error:not-logged-in]]'));
} else if (!data || !data.pid || !data.content) { } else if (!data || !data.pid || !data.content) {
return callback(new Error('[[error:invalid-data]]')); 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 + ']]')); return callback(new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]'));
} else if (data.title && data.title.length > parseInt(meta.config.maximumTitleLength, 10)) { } else if (data.title && data.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 + ']]'));
@ -28,7 +30,7 @@ module.exports = function (SocketPosts) {
return callback(new Error('[[error:not-enough-tags, ' + meta.config.minimumTagsPerTopic + ']]')); return callback(new Error('[[error:not-enough-tags, ' + meta.config.minimumTagsPerTopic + ']]'));
} else if (data.tags && data.tags.length > parseInt(meta.config.maximumTagsPerTopic, 10)) { } else if (data.tags && data.tags.length > parseInt(meta.config.maximumTagsPerTopic, 10)) {
return callback(new Error('[[error:too-many-tags, ' + meta.config.maximumTagsPerTopic + ']]')); 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 + ']]')); return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
} else if (contentLen > parseInt(meta.config.maximumPostLength, 10)) { } else if (contentLen > parseInt(meta.config.maximumPostLength, 10)) {
return callback(new Error('[[error:content-too-long, ' + meta.config.maximumPostLength + ']]')); return callback(new Error('[[error:content-too-long, ' + meta.config.maximumPostLength + ']]'));

Loading…
Cancel
Save