@@ -79,16 +79,16 @@ function ChatProxy(service, webrtcModule, conn) {
7979 extraParams = stanza . querySelector ( 'extraParams' ) ,
8080 delay = stanza . querySelector ( 'delay' ) ,
8181 messageId = stanza . getAttribute ( 'id' ) ,
82+ recipient = stanza . querySelector ( 'forwarded' ) ? stanza . querySelector ( 'forwarded' ) . querySelector ( 'message' ) . getAttribute ( 'to' ) : null ,
83+ recipientId = recipient ? self . helpers . getIdFromNode ( recipient ) : null ,
8284 dialogId = type === 'groupchat' ? self . helpers . getDialogIdFromNode ( from ) : null ,
8385 userId = type === 'groupchat' ? self . helpers . getIdFromResource ( from ) : self . helpers . getIdFromNode ( from ) ,
8486 marker = delivered || read || null ;
8587
86-
8788 // ignore invite messages from MUC
8889 //
8990 if ( invite ) return true ;
9091
91-
9292 // parse extra params
9393 var extraParamsParsed ;
9494 if ( extraParams ) {
@@ -139,6 +139,7 @@ function ChatProxy(service, webrtcModule, conn) {
139139 var message = {
140140 id : messageId ,
141141 dialog_id : dialogId ,
142+ recipient_id : recipientId ,
142143 type : type ,
143144 body : ( body && body . textContent ) || null ,
144145 extension : extraParamsParsed ? extraParamsParsed . extension : null ,
@@ -329,22 +330,31 @@ ChatProxy.prototype = {
329330 switch ( status ) {
330331 case Strophe . Status . ERROR :
331332 err = Utils . getError ( 422 , 'Status.ERROR - An error has occurred' ) ;
332- if ( typeof callback === 'function' ) callback ( err , null ) ;
333+ if ( typeof callback === 'function' ) {
334+ callback ( err , null ) ;
335+ }
333336 break ;
334337 case Strophe . Status . CONNECTING :
335338 Utils . QBLog ( '[ChatProxy]' , 'Status.CONNECTING' ) ;
336339 Utils . QBLog ( '[ChatProxy]' , 'Chat Protocol - ' + ( config . chatProtocol . active === 1 ? 'BOSH' : 'WebSocket' ) ) ;
337340 break ;
338341 case Strophe . Status . CONNFAIL :
339342 err = Utils . getError ( 422 , 'Status.CONNFAIL - The connection attempt failed' ) ;
340- if ( typeof callback === 'function' ) callback ( err , null ) ;
343+ if ( typeof callback === 'function' ) {
344+ callback ( err , null ) ;
345+ }
341346 break ;
342347 case Strophe . Status . AUTHENTICATING :
343348 Utils . QBLog ( '[ChatProxy]' , 'Status.AUTHENTICATING' ) ;
344349 break ;
345350 case Strophe . Status . AUTHFAIL :
346351 err = Utils . getError ( 401 , 'Status.AUTHFAIL - The authentication attempt failed' ) ;
347- if ( typeof callback === 'function' ) callback ( err , null ) ;
352+ if ( typeof callback === 'function' ) {
353+ callback ( err , null ) ;
354+ }
355+ if ( self . _isDisconnected && typeof self . onReconnectFailedListener === 'function' ) {
356+ Utils . safeCallbackCall ( self . onReconnectFailedListener , err ) ;
357+ }
348358 break ;
349359 case Strophe . Status . CONNECTED :
350360 Utils . QBLog ( '[ChatProxy]' , 'Status.CONNECTED at ' + getLocalTime ( ) ) ;
0 commit comments