1010 . get ( handleInboundSms )
1111 . post ( handleInboundSms ) ;
1212
13- let concat_sms = [ ] ; // Array of message objects
13+ const concat_sms = [ ] ; // Array of message objects
1414
15- function handleInboundSms ( request , response ) {
15+ const handleInboundSms = ( request , response ) => {
1616 const params = Object . assign ( request . query , request . body ) ;
17-
18- if ( params [ 'concat' ] === 'true' ) {
17+ console . dir ( params )
18+ if ( params [ 'concat' ] == 'true' ) {
1919 /* This is a concatenated message. Add it to an array
2020 so that we can process it later. */
2121 concat_sms . push ( {
@@ -27,9 +27,7 @@ function handleInboundSms(request, response) {
2727
2828 /* Do we have all the message parts yet? They might
2929 not arrive consecutively. */
30- let parts_for_ref = concat_sms . filter ( function ( part ) {
31- return part . ref == params [ 'concat-ref' ] ;
32- } ) ;
30+ const parts_for_ref = concat_sms . filter ( part => part . ref == params [ 'concat-ref' ] ) ;
3331
3432 // Is this the last message part for this reference?
3533 if ( parts_for_ref . length == params [ 'concat-total' ] ) {
@@ -45,31 +43,24 @@ function handleInboundSms(request, response) {
4543 response . status ( 204 ) . send ( ) ;
4644}
4745
48- function processConcatSms ( all_parts ) {
49-
50- // Order all the message parts
51- all_parts . sort ( function ( a , b ) {
52- if ( Number ( a . part ) < Number ( b . part ) ) {
53- return - 1 ;
54- } else {
55- return 1 ;
56- }
57- } )
46+ const processConcatSms = ( all_parts ) => {
5847
59- let concat_message = '' ;
48+ // Sort the message parts
49+ all_parts . sort ( ( a , b ) => a . part - b . part ) ;
6050
6151 // Reassemble the message from the parts
52+ let concat_message = '' ;
6253 for ( i = 0 ; i < all_parts . length ; i ++ ) {
6354 concat_message += all_parts [ i ] . message ;
6455 }
6556
6657 displaySms ( all_parts [ 0 ] . from , concat_message ) ;
6758}
6859
69- function displaySms ( msisdn , text ) {
60+ const displaySms = ( msisdn , text ) => {
7061 console . log ( 'FROM: ' + msisdn ) ;
7162 console . log ( 'MESSAGE: ' + text ) ;
7263 console . log ( '---' ) ;
7364}
7465
75- app . listen ( process . env . PORT ) ;
66+ app . listen ( process . env . PORT ) ;
0 commit comments