aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-04-16 18:14:36 +0000
committerAdam Soltys <[email protected]>2023-04-16 18:16:59 +0000
commite1beafc2c1add04495fe31475aa344c5219e525c (patch)
treee76df5d71c5fa16d3a17a40ec384ed0f275159ea /lib
parentd404f11e5df3c982ed91e4cddd2fbc9de6870262 (diff)
downloadcoinos-server-e1beafc2c1add04495fe31475aa344c5219e525c.tar.gz
coinos-server-e1beafc2c1add04495fe31475aa344c5219e525c.zip
ip and lnurl fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/countries.js2
-rw-r--r--lib/sockets.js4
2 files changed, 4 insertions, 2 deletions
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;