From 9338328a82ae1e4949de47aa39de243a41066acc Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 13 Aug 2022 22:26:13 +0200 Subject: [PATCH] fix: Add expiry to socket<->user mapping in Redis --- server/services/websockets.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/services/websockets.ts b/server/services/websockets.ts index 662613c50..901e3b2a0 100644 --- a/server/services/websockets.ts +++ b/server/services/websockets.ts @@ -294,6 +294,8 @@ async function authenticate(socket: SocketWithAuth, data: { token: string }) { socket.client.user = user; // store the mapping between socket id and user id in redis so that it is - // accessible across multiple websocket servers + // accessible across multiple websocket servers. Lasts 24 hours, if they have + // a websocket connection that lasts this long then well done. await Redis.defaultClient.hset(socket.id, "userId", user.id); + await Redis.defaultClient.expire(socket.id, 3600 * 24); }