@@ -2,6 +2,7 @@ package main
2
2
3
3
import (
4
4
verify "collab/verify"
5
+ "context"
5
6
"encoding/json"
6
7
"io"
7
8
"log"
@@ -226,7 +227,7 @@ func handleMessages(
226
227
log .Println ("Authentication failed - no token attached" )
227
228
client .conn .WriteMessage (
228
229
websocket .TextMessage ,
229
- []byte ("Authentication failed - no JWT token " ),
230
+ []byte ("Authentication failed" ),
230
231
)
231
232
client .conn .Close ()
232
233
break
@@ -248,12 +249,16 @@ func handleMessages(
248
249
if ! isSuccess {
249
250
client .conn .WriteMessage (
250
251
websocket .TextMessage ,
251
- []byte ("Authentication failed - failed to find a matching room " ),
252
+ []byte ("Authentication failed" ),
252
253
)
253
254
client .conn .Close ()
254
255
break
255
256
}
256
257
client .authenticated = true
258
+ client .conn .WriteMessage (
259
+ websocket .TextMessage ,
260
+ []byte ("Auth Success" ),
261
+ )
257
262
log .Println ("Client authenticated successfully" )
258
263
}
259
264
// i can comment out this whole block and it would work
@@ -277,6 +282,20 @@ func handleMessages(
277
282
RoomID : client .roomID ,
278
283
Content : []byte ("The session has been closed by a user." ),
279
284
}
285
+ targetId := msgData ["userId" ].(string )
286
+ data , err := persistMappings .Conn .HGetAll (context .Background (), targetId ).Result ()
287
+ if err != nil {
288
+ log .Printf ("Error retrieving data for userID %s: %v" , targetId , err )
289
+ } else {
290
+ _ , err1 := persistMappings .Conn .Del (context .Background (), targetId ).Result ()
291
+ if err1 != nil {
292
+ log .Printf ("Error deleting data for userID %s: %v" , targetId , err1 );
293
+ }
294
+ _ , err2 := persistMappings .Conn .Del (context .Background (), data ["otherUser" ]).Result ()
295
+ if err2 != nil {
296
+ log .Printf ("Error deleting data for other user %s: %v" , data ["otherUser" ], err2 );
297
+ }
298
+ }
280
299
hub .broadcast <- closeMessage
281
300
}
282
301
0 commit comments