From 0b019a93a57f6f8fc9c3b9af8f003a61ebaee7de Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 29 Jan 2025 05:30:02 +0000 Subject: stringify follows --- lib/nostr.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/nostr.ts b/lib/nostr.ts index aca518b6..0bb01521 100644 --- a/lib/nostr.ts +++ b/lib/nostr.ts @@ -158,7 +158,7 @@ export const getCount = async (pubkey) => { if (follows === null) { const result = await get({ authors: [pubkey], kinds: [3] }); follows = result ? result.tags.filter((t) => t[0] === "p").length : 0; - await db.set(`${pubkey}:follows:n`, follows, { EX }); + if (follows?.length) await db.set(`${pubkey}:follows:n`, JSON.stringify(follows), { EX }); } const k = `${pubkey}:followers:n`; @@ -169,7 +169,8 @@ export const getCount = async (pubkey) => { "#p": [pubkey], kinds: [3], }); - await db.set(k, followers, { EX }); + + if (followers?.length) await db.set(k, JSON.stringify(followers), { EX }); } return { follows, followers }; -- cgit v1.2.3