@@ -35,7 +35,7 @@ io.on('connection', (socket) => {
35
35
if ( typeof data === 'object' ) {
36
36
// Make sure the data received is a JS object
37
37
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 ) {
39
39
// Check if the fields are present
40
40
console . log ( `${ now } - Event had invalid fields.` )
41
41
return ;
@@ -44,7 +44,8 @@ io.on('connection', (socket) => {
44
44
io . to ( data . roomName ) . emit ( 'chat response' , {
45
45
// Broadcasts the message to the Socket room
46
46
user_name : data . user_name ,
47
- message : data . message
47
+ message : data . message ,
48
+ hmac : data . hmac
48
49
} ) ;
49
50
return ;
50
51
}
@@ -138,18 +139,19 @@ io.on('connection', (socket) => {
138
139
var now = new Date ( ) ;
139
140
140
141
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 ) {
150
143
console . log ( `${ now } - Event had invalid fields.` ) ;
144
+ return ;
151
145
}
152
146
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
+
153
155
io . to ( socket . id ) . emit ( 'file progress' , {
154
156
finished : true
155
157
} ) ;
0 commit comments