aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-11 21:34:18 -0700
committerAdam Soltys <[email protected]>2024-10-11 21:34:18 -0700
commit8b2aae9b29649df4ee2aff21b0864da0982d5cd4 (patch)
treec0861f1b45f5d234d5e650f3b9786cfb2f4cb1ab /lib
parentb6f56cec418247a3cfb71f2d9f44e9c843354829 (diff)
downloadcoinos-server-8b2aae9b29649df4ee2aff21b0864da0982d5cd4.tar.gz
coinos-server-8b2aae9b29649df4ee2aff21b0864da0982d5cd4.zip
check invoice id not hash
Diffstat (limited to 'lib')
-rw-r--r--lib/sockets.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/sockets.ts b/lib/sockets.ts
index 6ac75cb8..4ee8e00e 100644
--- a/lib/sockets.ts
+++ b/lib/sockets.ts
@@ -14,7 +14,7 @@ export const emit = (uid, type, data) => {
for (let i = subscriptions.length - 1; i >= 0; i--) {
let s = subscriptions[i];
- if (s.invoice && s.invoice.hash === data.hash) {
+ if (s.invoice && s.invoice.id === data.iid) {
s.ws.send(JSON.stringify({ type, data }));
}
}
@@ -37,7 +37,7 @@ export const broadcast = (type, data) => {
}
}
- Object.values(all).map((ws) => {
+ Object.values(all).map((ws: any) => {
if (!sent.includes(ws.id)) ws.send(JSON.stringify({ type, data }));
});
};
@@ -74,7 +74,7 @@ Bun.serve({
return new Response("Upgrade failed", { status: 500 });
},
websocket: {
- async message(ws, message) {
+ async message(ws: any, message: string) {
let type, data;
try {
@@ -123,14 +123,14 @@ Bun.serve({
warn("received socket message of unknown type", type, data);
}
},
- open(ws) {
+ open(ws: any) {
const id = v4();
ws.id = id;
ws.beats = 0;
ws.send(JSON.stringify({ type: "connected", data: id }));
all[id] = ws;
},
- close(ws) {
+ close(ws: any) {
let { id } = ws;
try {
const uid = users[id];