diff options
| author | Adam Soltys <[email protected]> | 2024-10-10 16:49:43 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-10 16:49:43 -0700 |
| commit | 9edc16aa2d56ab5039cfb29cdfc1292da0ed6290 (patch) | |
| tree | 45fb76432994562bca8e70a9ad61d3782524367e /lib | |
| parent | 17656bfe7346bfb1c948e3c82d9960b5a795621f (diff) | |
| download | coinos-server-9edc16aa2d56ab5039cfb29cdfc1292da0ed6290.tar.gz coinos-server-9edc16aa2d56ab5039cfb29cdfc1292da0ed6290.zip | |
check for event
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/nostr.ts | 9 |
1 files changed, 5 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 }); |
