Browse Source

Limit chat message send size to 200000 characters to avoid hanging clients.

pull/183/head
Simon Eisenmann 10 years ago
parent
commit
d13e59c749
  1. 8
      static/js/directives/chat.js
  2. 2
      static/partials/chatroom.html

8
static/js/directives/chat.js

@ -26,6 +26,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -26,6 +26,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
var displayName = safeDisplayName;
var groupChatId = "";
var maxMessageSize = 200000;
var controller = ['$scope', '$element', '$attrs', function($scope, $element, $attrs) {
@ -42,6 +43,8 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -42,6 +43,8 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
$scope.currentRoom = null;
$scope.currentRoomActive = false;
$scope.maxMessageSize = maxMessageSize;
$scope.getVisibleRooms = function() {
var res = [];
for (var i = 0; i < ctrl.visibleRooms.length; i++) {
@ -245,6 +248,10 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -245,6 +248,10 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
};
subscope.sendChat = function(to, message, status, mid, noloop) {
//console.log("send chat", to, scope.peer);
if (message && message.length > maxMessageSize) {
console.log("XXXXXXX", message.length);
return mid;
}
var peercall = mediaStream.webrtc.findTargetCall(to);
if (peercall && peercall.peerconnection && peercall.peerconnection.datachannelReady) {
subscope.p2p(true);
@ -254,7 +261,6 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -254,7 +261,6 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
subscope.p2p(false);
return subscope.sendChatServer(to, message, status, mid, noloop);
}
return mid;
};
subscope.sendChatPeer2Peer = function(peercall, to, message, status, mid, noloop) {
if (message && !mid) {

2
static/partials/chatroom.html

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
</div>
<div class="inputbox">
<div>
<textarea class="input nicescroll form-control" ng-disabled="!(enabled)" on-enter="submit()" ng-model="input" placeholder="{{_('Type here to chat...')}}"/>
<textarea class="input nicescroll form-control" maxlength="{{maxMessageSize}}" ng-disabled="!(enabled)" on-enter="submit()" ng-model="input" placeholder="{{_('Type here to chat...')}}"/>
</div>
<a ng-disabled="!(enabled)" ng-click="submit()" title="{{_('Send')}}" class="btn btn-small btn-info fa fa-play"></a>
</div>

Loading…
Cancel
Save