From 81a576c2007805849f963242bc93ef60bee8efa4 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 14 Jan 2025 16:55:44 -0800 Subject: public fields --- routes/nostr.ts | 19 +++++++------------ routes/users.ts | 4 ++-- 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'routes') diff --git a/routes/nostr.ts b/routes/nostr.ts index 6c252927..ae2be7e9 100644 --- a/routes/nostr.ts +++ b/routes/nostr.ts @@ -1,21 +1,18 @@ import config from "$config"; -import { db, g, s } from "$lib/db"; +import { db, g } from "$lib/db"; import { anon, getCount, getProfile, getRelays, - pool, send, serverPubkey, } from "$lib/nostr"; -import { count, scan } from "$lib/strfry"; -import { bail, fail, getUser, publicFields } from "$lib/utils"; +import { scan } from "$lib/strfry"; +import { bail, fail, fields, getUser } from "$lib/utils"; import { decode } from "nostr-tools/nip19"; import type { ProfilePointer } from "nostr-tools/nip19"; -const opts = { maxWait: 2000 }; - export default { async event(req, res) { const { @@ -78,7 +75,7 @@ export default { const profiles = await scan({ authors: pubkeys, kinds: [0] }); for (const p of profiles) { const { content, pubkey } = p; - let user = await getUser(pubkey, publicFields); + let user = await getUser(pubkey, fields); user = { ...user, ...JSON.parse(content) }; user.pubkey = pubkey; follows.push(user); @@ -89,8 +86,7 @@ export default { pubkeys .filter((p) => !keys.includes(p)) .map( - async (pubkey) => - (await getUser(pubkey, publicFields)) || anon(pubkey), + async (pubkey) => (await getUser(pubkey, fields)) || anon(pubkey), ), ); @@ -120,7 +116,7 @@ export default { const profiles = await scan({ authors: pubkeys, kinds: [0] }); for (const p of profiles) { const { content, pubkey } = p; - let user = await getUser(pubkey, publicFields); + let user = await getUser(pubkey, fields); user = { ...user, ...JSON.parse(content) }; user.pubkey = pubkey; followers.push(user); @@ -131,8 +127,7 @@ export default { pubkeys .filter((p) => !keys.includes(p)) .map( - async (pubkey) => - (await getUser(pubkey, publicFields)) || anon(pubkey), + async (pubkey) => (await getUser(pubkey, fields)) || anon(pubkey), ), ); diff --git a/routes/users.ts b/routes/users.ts index dc3636e8..1da397ca 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -10,7 +10,7 @@ import { reconcile, types } from "$lib/payments"; import register from "$lib/register"; import { emit } from "$lib/sockets"; import upload from "$lib/upload"; -import { bail, fail, publicFields, getUser, pick } from "$lib/utils"; +import { bail, fail, fields, getUser, pick } from "$lib/utils"; import whitelist from "$lib/whitelist"; import rpc from "@coinos/rpc"; import { bytesToHex, randomBytes } from "@noble/hashes/utils"; @@ -117,7 +117,7 @@ export default { if (user.pubkey) user.npub = nip19.npubEncode(user.pubkey); user.prompt = !!user.prompt; - res.send(pick(user, publicFields)); + res.send(pick(user, fields)); } catch (e) { err("problem getting user", e.message); res.code(500).send(e.message); -- cgit v1.2.3