From 15b667850edae8f094abecd2c0b18b1e93059ba2 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 14 Sep 2015 17:42:06 -0400 Subject: [PATCH] closes #3595 --- public/language/en_GB/error.json | 2 ++ src/messaging.js | 12 ++++++++++-- src/views/admin/partials/menu.tpl | 1 + src/views/admin/settings/chat.tpl | 2 +- src/views/admin/settings/post.tpl | 9 --------- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.json index 3419301602..252e893d0d 100644 --- a/public/language/en_GB/error.json +++ b/public/language/en_GB/error.json @@ -100,6 +100,8 @@ "cant-chat-with-yourself": "You can't chat with yourself!", "chat-restricted": "This user has restricted their chat messages. They must follow you before you can chat with them", "too-many-messages": "You have sent too many messages, please wait awhile.", + "invalid-chat-message": "Invalid chat message", + "chat-message-too-long": "Chat message is too long", "reputation-system-disabled": "Reputation system is disabled.", "downvoting-disabled": "Downvoting is disabled", diff --git a/src/messaging.js b/src/messaging.js index 81a0a5fe4c..6b0e2318bf 100644 --- a/src/messaging.js +++ b/src/messaging.js @@ -28,8 +28,6 @@ var db = require('./database'), } Messaging.addMessage = function(fromuid, touid, content, timestamp, callback) { - var uids = sortUids(fromuid, touid); - if (typeof timestamp === 'function') { callback = timestamp; timestamp = Date.now(); @@ -37,6 +35,16 @@ var db = require('./database'), timestamp = timestamp || Date.now(); } + if (!content) { + return callback(new Error('[[error:invalid-chat-message]]')); + } + + if (content.length > (meta.config.maximumChatMessageLength || 1000)) { + return callback(new Error('[[error:chat-message-too-long]]')); + } + + var uids = sortUids(fromuid, touid); + db.incrObjectField('global', 'nextMid', function(err, mid) { if (err) { return callback(err); diff --git a/src/views/admin/partials/menu.tpl b/src/views/admin/partials/menu.tpl index 55ca6f5839..183adbb3e3 100644 --- a/src/views/admin/partials/menu.tpl +++ b/src/views/admin/partials/menu.tpl @@ -182,6 +182,7 @@
  • Group
  • Guests
  • Post
  • +
  • Chat
  • Pagination
  • Tags
  • Notifications
  • diff --git a/src/views/admin/settings/chat.tpl b/src/views/admin/settings/chat.tpl index 66b1361c70..4238ecbb63 100644 --- a/src/views/admin/settings/chat.tpl +++ b/src/views/admin/settings/chat.tpl @@ -10,7 +10,7 @@
    - +
    diff --git a/src/views/admin/settings/post.tpl b/src/views/admin/settings/post.tpl index 8697b81f4b..b669021204 100644 --- a/src/views/admin/settings/post.tpl +++ b/src/views/admin/settings/post.tpl @@ -114,15 +114,6 @@ -
    -
    Chat Settings
    -
    -
    - Chat Message Inbox Size
    -
    -
    -
    -
    Upload Settings