Skip to content
Snippets Groups Projects
Commit ee8f84ad authored by Gabriel Engel's avatar Gabriel Engel
Browse files

Merge pull request #403 from thebakeryio/fix/limit-maximum-message-size

Limit maximum message size
parents 95539c8b 292adc48
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ class @ChatMessages ...@@ -2,6 +2,7 @@ class @ChatMessages
init: (node) -> init: (node) ->
this.editing = {} this.editing = {}
this.messageMaxSize = RocketChat.settings.get('Message_MaxAllowedSize')
this.wrapper = $(node).find(".wrapper") this.wrapper = $(node).find(".wrapper")
this.input = $(node).find(".input-message").get(0) this.input = $(node).find(".input-message").get(0)
this.bindEvents() this.bindEvents()
...@@ -65,7 +66,8 @@ class @ChatMessages ...@@ -65,7 +66,8 @@ class @ChatMessages
this.editing.saved = this.input.value this.editing.saved = this.input.value
send: (rid, input) -> send: (rid, input) ->
if _.trim(input.value) isnt '' if _.trim(input.value) isnt '' and not this.isMessageTooLong(input)
console.error 'sending', input.value
KonchatNotification.removeRoomNotification(rid) KonchatNotification.removeRoomNotification(rid)
msg = input.value msg = input.value
input.value = '' input.value = ''
...@@ -185,3 +187,6 @@ class @ChatMessages ...@@ -185,3 +187,6 @@ class @ChatMessages
# ctrl (command) + shift + k -> clear room messages # ctrl (command) + shift + k -> clear room messages
else if k is 75 and ((navigator?.platform?.indexOf('Mac') isnt -1 and event.metaKey and event.shiftKey) or (navigator?.platform?.indexOf('Mac') is -1 and event.ctrlKey and event.shiftKey)) else if k is 75 and ((navigator?.platform?.indexOf('Mac') isnt -1 and event.metaKey and event.shiftKey) or (navigator?.platform?.indexOf('Mac') is -1 and event.ctrlKey and event.shiftKey))
RoomHistoryManager.clear rid RoomHistoryManager.clear rid
isMessageTooLong: (input) ->
input?.value.length > this.messageMaxSize
\ No newline at end of file
...@@ -266,6 +266,8 @@ Template.room.helpers ...@@ -266,6 +266,8 @@ Template.room.helpers
noRtcLayout: -> noRtcLayout: ->
return (!Session.get('rtcLayoutmode') || (Session.get('rtcLayoutmode') == 0) ? true: false); return (!Session.get('rtcLayoutmode') || (Session.get('rtcLayoutmode') == 0) ? true: false);
maxMessageLength: ->
return RocketChat.settings.get('Message_MaxAllowedSize')
Template.room.events Template.room.events
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<form class="message-form" method="post" action="/"> <form class="message-form" method="post" action="/">
<div> <div>
{{> messagePopupConfig getPupupConfig}} {{> messagePopupConfig getPupupConfig}}
<textarea dir="auto" name="msg" class="input-message"></textarea> <textarea dir="auto" name="msg" maxlength="{{maxMessageLength}}" class="input-message"></textarea>
<i class="icon-paper-plane" title="{{_ "Send_Message"}}"></i> <i class="icon-paper-plane" title="{{_ "Send_Message"}}"></i>
</div> </div>
<div class="users-typing"> <div class="users-typing">
......
...@@ -22,6 +22,7 @@ Meteor.startup -> ...@@ -22,6 +22,7 @@ Meteor.startup ->
RocketChat.settings.add 'Message_ShowEditedStatus', '', { type: 'string', group: 'Message' } RocketChat.settings.add 'Message_ShowEditedStatus', '', { type: 'string', group: 'Message' }
RocketChat.settings.add 'Message_ShowDeletedStatus', '', { type: 'string', group: 'Message' } RocketChat.settings.add 'Message_ShowDeletedStatus', '', { type: 'string', group: 'Message' }
RocketChat.settings.add 'Message_KeepStatusHistory', '', { type: 'string', group: 'Message' } RocketChat.settings.add 'Message_KeepStatusHistory', '', { type: 'string', group: 'Message' }
RocketChat.settings.add 'Message_MaxAllowedSize', 500, { type: 'int', group: 'Message', public: true }
RocketChat.settings.addGroup 'Meta' RocketChat.settings.addGroup 'Meta'
RocketChat.settings.add 'Meta:language', '', { type: 'string', group: 'Meta' } RocketChat.settings.add 'Meta:language', '', { type: 'string', group: 'Meta' }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment