diff options
| author | Adam Soltys <[email protected]> | 2024-10-11 21:34:18 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-11 21:34:18 -0700 |
| commit | 8b2aae9b29649df4ee2aff21b0864da0982d5cd4 (patch) | |
| tree | c0861f1b45f5d234d5e650f3b9786cfb2f4cb1ab /lib/sockets.ts | |
| parent | b6f56cec418247a3cfb71f2d9f44e9c843354829 (diff) | |
| download | coinos-server-8b2aae9b29649df4ee2aff21b0864da0982d5cd4.tar.gz coinos-server-8b2aae9b29649df4ee2aff21b0864da0982d5cd4.zip | |
check invoice id not hash
Diffstat (limited to 'lib/sockets.ts')
| -rw-r--r-- | lib/sockets.ts | 10 |
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]; |
