aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-01-14 16:55:44 -0800
committerAdam Soltys <[email protected]>2025-01-14 16:55:44 -0800
commit81a576c2007805849f963242bc93ef60bee8efa4 (patch)
treecfb4e4f62f749b658271d91f03d819ed698b1da3 /routes
parent0a8a8988d27d26feec689a28447eed85c1069584 (diff)
downloadcoinos-server-81a576c2007805849f963242bc93ef60bee8efa4.tar.gz
coinos-server-81a576c2007805849f963242bc93ef60bee8efa4.zip
public fields
Diffstat (limited to 'routes')
-rw-r--r--routes/nostr.ts19
-rw-r--r--routes/users.ts4
2 files changed, 9 insertions, 14 deletions
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);