diff --git a/public/src/client/chats/messages.js b/public/src/client/chats/messages.js index 9828f4d065..b6a8ce9b1c 100644 --- a/public/src/client/chats/messages.js +++ b/public/src/client/chats/messages.js @@ -8,10 +8,6 @@ define('forum/chats/messages', ['components', 'sounds', 'translator', 'benchpres var msg = inputEl.val(); 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) { return; } diff --git a/src/messaging/create.js b/src/messaging/create.js index 7380ff6f89..c173528c65 100644 --- a/src/messaging/create.js +++ b/src/messaging/create.js @@ -30,13 +30,20 @@ module.exports = function (Messaging) { if (!content) { return callback(new Error('[[error:invalid-chat-message]]')); } - content = String(content); - var maximumChatMessageLength = (meta.config.maximumChatMessageLength || 1000); - if (content.length > maximumChatMessageLength) { - return callback(new Error('[[error:chat-message-too-long, ' + maximumChatMessageLength + ']]')); - } - callback(); + plugins.fireHook('filter:messaging.checkContent', { content: content }, function (err, data) { + if (err) { + return callback(err); + } + + 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) {