diff options
| author | Adam Soltys <[email protected]> | 2024-10-04 09:29:21 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-10 12:17:05 -0700 |
| commit | 372c635714f6e7de8a0da135980697b49f207f2c (patch) | |
| tree | 5c5af794a4ca18b0919cc363f65fd398bc051b8b /routes/nostr.ts | |
| parent | 5127adbb54b7db6eccf27cc4e498d9dfcdb7a7a4 (diff) | |
| download | coinos-server-372c635714f6e7de8a0da135980697b49f207f2c.tar.gz coinos-server-372c635714f6e7de8a0da135980697b49f207f2c.zip | |
wip socket communication
Diffstat (limited to 'routes/nostr.ts')
| -rw-r--r-- | routes/nostr.ts | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/routes/nostr.ts b/routes/nostr.ts index 9bbff33d..d3c293c6 100644 --- a/routes/nostr.ts +++ b/routes/nostr.ts @@ -27,8 +27,7 @@ export default { let { params: { pubkey }, } = req; - let uid = await g(`user:${pubkey}`); - let user = await g(`user:${uid}`); + let user = await getUser(pubkey); if (!user) user = { @@ -121,24 +120,29 @@ export default { if (tagsonly) return res.send(tags); let follows = []; + + console.log("L", tags.length); + for (let f of tags) { let [_, pubkey] = f; + let user = await getUser(pubkey); - q(`${pubkey}:profile:f1`, { - limit: 1, - kinds: [0], - authors: [pubkey], - }).catch(nada); - - let uid = await g(`user:${pubkey}`); - let user = await g(`user:${uid}`); + if (!(user && user.updated)) { + console.log("Q", pubkey) + q(`${pubkey}:profile:f1`, { + limit: 1, + kinds: [0], + authors: [pubkey], + }).catch(nada); + } - if (!user) + if (!user) { user = { username: pubkey.substr(0, 6), pubkey, anon: true, }; + } follows.push(user); } @@ -172,17 +176,14 @@ export default { ).catch(nada); for (let pubkey of pubkeys) { - let uid = await g(`user:${pubkey}`); - let user = await g(`user:${uid}`); - if (!user || !user.updated) { - await q(`${pubkey}:profile:f2`, { + let user = await getUser(pubkey); + + if (!user?.updated) { + q(`${pubkey}:profile:f2`, { limit: 1, kinds: [0], authors: [pubkey], }).catch(nada); - - uid = await g(`user:${pubkey}`); - user = await g(`user:${uid}`); } if (!user) |
