@@ -35,7 +35,7 @@ io.on('connection', (socket) => {
3535 if ( typeof data === 'object' ) {
3636 // Make sure the data received is a JS object
3737 var now = new Date ( ) ;
38- if ( data . roomName === undefined || data . user_name === undefined || data . message === undefined ) {
38+ if ( data . roomName === undefined || data . user_name === undefined || data . message === undefined || data . hmac === undefined ) {
3939 // Check if the fields are present
4040 console . log ( `${ now } - Event had invalid fields.` )
4141 return ;
@@ -44,7 +44,8 @@ io.on('connection', (socket) => {
4444 io . to ( data . roomName ) . emit ( 'chat response' , {
4545 // Broadcasts the message to the Socket room
4646 user_name : data . user_name ,
47- message : data . message
47+ message : data . message ,
48+ hmac : data . hmac
4849 } ) ;
4950 return ;
5051 }
@@ -138,18 +139,19 @@ io.on('connection', (socket) => {
138139 var now = new Date ( ) ;
139140
140141 console . log ( `${ now } - File event received` )
141-
142- try {
143- io . to ( data . roomName ) . emit ( 'file response' , {
144- user_name : data . user_name ,
145- name : data . name ,
146- type : data . type ,
147- data : data . data
148- } ) ;
149- } catch ( err ) {
142+ if ( data . user_name === undefined || data . name === undefined || data . type === undefined || data . data === undefined || data . hmac === undefined ) {
150143 console . log ( `${ now } - Event had invalid fields.` ) ;
144+ return ;
151145 }
152146
147+ io . to ( data . roomName ) . emit ( 'file response' , {
148+ user_name : data . user_name ,
149+ name : data . name ,
150+ type : data . type ,
151+ data : data . data ,
152+ hmac : data . hmac
153+ } ) ;
154+
153155 io . to ( socket . id ) . emit ( 'file progress' , {
154156 finished : true
155157 } ) ;
0 commit comments