diff options
| -rw-r--r-- | lib/nostr.ts | 9 | ||||
| -rw-r--r-- | routes/nostr.ts | 1 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/nostr.ts b/lib/nostr.ts index 10817c71..40dfc5f6 100644 --- a/lib/nostr.ts +++ b/lib/nostr.ts @@ -165,9 +165,10 @@ export let getCount = async (pubkey) => { let cache = await g(`${pubkey}:follows:n`); if (cache && cache.t >= created_at) ({ follows } = cache); else { - follows = ev.tags - .map((t) => t[0] === "p" && t[1]) - .filter((p) => p && p.length === 64).length; + if (ev) + follows = ev.tags + .map((t) => t[0] === "p" && t[1]) + .filter((p) => p && p.length === 64).length; await s(`${pubkey}:follows:n`, { follows, t: created_at }); } @@ -185,7 +186,7 @@ export let getCount = async (pubkey) => { let f = infos.find((e) => e.kind === 10000133); let counts = {}; - if (f) { + if (f && f.content) { counts = JSON.parse(f.content); followers = counts[pubkey]; await s(`${pubkey}:followers:n`, { followers, t: created_at }); diff --git a/routes/nostr.ts b/routes/nostr.ts index f03af265..0230f712 100644 --- a/routes/nostr.ts +++ b/routes/nostr.ts @@ -166,6 +166,7 @@ export default { let { pubkey } = req.params; res.send(await getCount(pubkey)); } catch (e) { + console.log(e) bail(res, e.message); } }, |
