From e1beafc2c1add04495fe31475aa344c5219e525c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 16 Apr 2023 18:14:36 +0000 Subject: ip and lnurl fixes --- lib/countries.js | 2 +- lib/sockets.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/countries.js b/lib/countries.js index 4d5a48dc..9e1ecddb 100644 --- a/lib/countries.js +++ b/lib/countries.js @@ -34,7 +34,7 @@ export default { BI: "BDI", KH: "KHM", CM: "CMR", - CA: "CAN", + CA: "CAD", IC: "EUR", CV: "CVE", KY: "KYD", diff --git a/lib/sockets.js b/lib/sockets.js index e5f2638b..c42c9c7a 100644 --- a/lib/sockets.js +++ b/lib/sockets.js @@ -49,17 +49,19 @@ export const broadcast = (type, data) => { let track = async (ws, token) => { let { id } = ws; let { id: uid } = jwt.decode(token); + if (!uid) throw new Error("Invalid JWT token"); let user = await g(`user:${uid}`); if (!user) throw new Error("User not found"); if (!store.sockets[uid]) store.sockets[uid] = {}; - if (store.sockets[uid][id]) return; + const existing = Object.keys(store.sockets[uid]); if (existing.length > 4) { const p = existing.find(sid => sid !== uid); store.sockets[uid][p].close(code, "too many sockets"); } + store.sockets[uid][id] = ws; users[id] = uid; ws.user = user; -- cgit v1.2.3