File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -272,14 +272,22 @@ export class ChatConnector implements IConnector, IBotStorage {
272
272
try {
273
273
if ( msg . type == 'delay' ) {
274
274
setTimeout ( cb , ( < any > msg ) . value ) ;
275
- } else if ( msg . address && ( < IChatConnectorAddress > msg . address ) . serviceUrl ) {
276
- this . postMessage ( msg , ( idx == messages . length - 1 ) , ( err , address ) => {
277
- addresses . push ( address ) ;
278
- cb ( err ) ;
279
- } ) ;
280
275
} else {
281
- logger . error ( 'ChatConnector: send - message is missing address or serviceUrl.' )
282
- cb ( new Error ( 'Message missing address or serviceUrl.' ) ) ;
276
+ const addressExists = ! ! msg . address ;
277
+ const serviceUrlExists = addressExists && ! ! ( < IChatConnectorAddress > msg . address ) . serviceUrl ;
278
+
279
+ // checking for address exists is redundant here, its part of the def of serviceUrlExists
280
+ if ( serviceUrlExists ) {
281
+ this . postMessage ( msg , ( idx == messages . length - 1 ) , ( err , address ) => {
282
+ addresses . push ( address ) ;
283
+ cb ( err ) ;
284
+ } ) ;
285
+ } else {
286
+ const msg = `Message is missing ${ addressExists ? 'address and serviceUrl' : 'serviceUrl' } ` ;
287
+
288
+ logger . error ( `ChatConnector: send - ${ msg } ` )
289
+ cb ( new Error ( msg ) ) ;
290
+ }
283
291
}
284
292
} catch ( e ) {
285
293
cb ( e ) ;
You can’t perform that action at this time.
0 commit comments