aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-10 16:49:43 -0700
committerAdam Soltys <[email protected]>2024-10-10 16:49:43 -0700
commit9edc16aa2d56ab5039cfb29cdfc1292da0ed6290 (patch)
tree45fb76432994562bca8e70a9ad61d3782524367e
parent17656bfe7346bfb1c948e3c82d9960b5a795621f (diff)
downloadcoinos-server-9edc16aa2d56ab5039cfb29cdfc1292da0ed6290.tar.gz
coinos-server-9edc16aa2d56ab5039cfb29cdfc1292da0ed6290.zip
check for event
-rw-r--r--lib/nostr.ts9
-rw-r--r--routes/nostr.ts1
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);
}
},