removed client-side chat message length check in favour of server-side check, firing new hook on messaging.checkContent for hooks to intercept

v1.18.x
Julian Lam 6 years ago
parent e79f0dad90
commit 5c04ec2d63

@ -8,10 +8,6 @@ define('forum/chats/messages', ['components', 'sounds', 'translator', 'benchpres
var msg = inputEl.val(); var msg = inputEl.val();
var mid = inputEl.attr('data-mid'); var mid = inputEl.attr('data-mid');
if (msg.length > ajaxify.data.maximumChatMessageLength) {
return app.alertError('[[error:chat-message-too-long,' + ajaxify.data.maximumChatMessageLength + ']]');
}
if (!msg.length) { if (!msg.length) {
return; return;
} }

@ -30,13 +30,20 @@ module.exports = function (Messaging) {
if (!content) { if (!content) {
return callback(new Error('[[error:invalid-chat-message]]')); return callback(new Error('[[error:invalid-chat-message]]'));
} }
content = String(content);
var maximumChatMessageLength = (meta.config.maximumChatMessageLength || 1000); plugins.fireHook('filter:messaging.checkContent', { content: content }, function (err, data) {
if (content.length > maximumChatMessageLength) { if (err) {
return callback(new Error('[[error:chat-message-too-long, ' + maximumChatMessageLength + ']]')); return callback(err);
} }
callback();
content = String(data.content);
var maximumChatMessageLength = (meta.config.maximumChatMessageLength || 1000);
if (content.length > maximumChatMessageLength) {
return callback(new Error('[[error:chat-message-too-long, ' + maximumChatMessageLength + ']]'));
}
callback();
});
}; };
Messaging.addMessage = function (data, callback) { Messaging.addMessage = function (data, callback) {

Loading…
Cancel
Save