diff options
| author | Adam Soltys <[email protected]> | 2023-01-07 01:36:16 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-01-07 01:36:16 +0000 |
| commit | b02ba909998a8a61145eaaaadb3beb1845d4a151 (patch) | |
| tree | e99e0fecb52dcbd0e70f1d174c87c09ccea2c554 | |
| parent | e3266ddecd825b8716df7dc418246441d4dcb0f7 (diff) | |
| download | coinos-server-b02ba909998a8a61145eaaaadb3beb1845d4a151.tar.gz coinos-server-b02ba909998a8a61145eaaaadb3beb1845d4a151.zip | |
quiet
| -rw-r--r-- | lib/sockets.js | 2 | ||||
| -rw-r--r-- | routes/events.js | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/lib/sockets.js b/lib/sockets.js index 82cf3f51..5980304b 100644 --- a/lib/sockets.js +++ b/lib/sockets.js @@ -95,7 +95,7 @@ app.register(async function(app) { return ws.close(code, `bad token ${token}`); let { username, uuid } = jwt.decode(token); if (uuid) user = await getUser(uuid); - username = user.username; + if (user) ({ username } = user); if (!(username || uuid)) throw new Error("Invalid JWT token"); if (!store.sockets[username]) store.sockets[username] = {}; diff --git a/routes/events.js b/routes/events.js index bbdd8891..554be5d8 100644 --- a/routes/events.js +++ b/routes/events.js @@ -3,7 +3,7 @@ import db from "$db"; import redis from "$lib/redis"; import { coinos, pool, q } from "$lib/nostr"; import store from "$lib/store"; -import { wait } from "$lib/utils"; +import { nada, wait } from "$lib/utils"; app.get("/nostr/:pubkey", async (req, res) => { try { @@ -29,12 +29,11 @@ app.get("/nostr/:pubkey", async (req, res) => { q(`${pubkey}:notes`, { kinds: [1], authors: [pubkey] - }).catch(console.log); + }).catch(nada); await redis.set(`user:${pubkey}`, JSON.stringify(user)); let ids = await redis.sMembers(pubkey); - console.log("IDS", ids); let events = ids.length ? (await redis.mGet(ids.map(k => "ev:" + k))).map(JSON.parse) |
