From 36aa45206ce1b21adf5296cbcf11d89f11cb90e8 Mon Sep 17 00:00:00 2001 From: Alexander Zavorotynskiy Date: Mon, 19 Jun 2023 18:07:50 +0200 Subject: [PATCH] fix(assist): added meta header only for sessions from old tracker --- assist/servers/websocket.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assist/servers/websocket.js b/assist/servers/websocket.js index 1ef75ec32..48bf629f0 100644 --- a/assist/servers/websocket.js +++ b/assist/servers/websocket.js @@ -345,8 +345,8 @@ module.exports = { return } // Back compatibility (add top layer with meta information) - if (args[0].meta === undefined) { - args[0] = {meta: {tabId: socket.tabId}, data: args[0]}; + if (args[0]?.meta === undefined && socket.identity === IDENTITIES.session) { + args[0] = {meta: {tabId: socket.tabId, version: 1}, data: args[0]}; } Object.assign(socket.handshake.query.sessionInfo, args[0].data, {tabId: args[0].meta.tabId}); socket.to(socket.roomId).emit(EVENTS_DEFINITION.emit.UPDATE_EVENT, args[0]); @@ -373,7 +373,7 @@ module.exports = { return } // Back compatibility (add top layer with meta information) - if (args[0].meta === undefined && socket.identity === IDENTITIES.session) { + if (args[0]?.meta === undefined && socket.identity === IDENTITIES.session) { args[0] = {meta: {tabId: socket.tabId, version: 1}, data: args[0]}; } if (socket.identity === IDENTITIES.session) { @@ -382,7 +382,7 @@ module.exports = { socket.to(socket.roomId).emit(eventName, args[0]); } else { debug && console.log(`received event:${eventName}, from:${socket.identity}, sending message to session of room:${socket.roomId}`); - let socketId = await findSessionSocketId(io, socket.roomId, args[0].meta?.tabId); + let socketId = await findSessionSocketId(io, socket.roomId, args[0]?.meta?.tabId); if (socketId === null) { debug && console.log(`session not found for:${socket.roomId}`); io.to(socket.id).emit(EVENTS_DEFINITION.emit.NO_SESSIONS);