aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-01-20 00:19:09 -0800
committerAdam Soltys <[email protected]>2025-01-20 00:19:09 -0800
commit263ffd68ec8051dfad47d20fcb1ab1ea22ade520 (patch)
treeb3d2db9cfd9b7b8a5f1fd328cf8b55d9196862ab /routes/users.ts
parenta55eb812c4ea6dc9573f2bdf40f058a1d3ba90ee (diff)
downloadcoinos-server-263ffd68ec8051dfad47d20fcb1ab1ea22ade520.tar.gz
coinos-server-263ffd68ec8051dfad47d20fcb1ab1ea22ade520.zip
nostr threads
Diffstat (limited to 'routes/users.ts')
-rw-r--r--routes/users.ts36
1 files changed, 3 insertions, 33 deletions
diff --git a/routes/users.ts b/routes/users.ts
index 4bc54bd6..9b0fd240 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -5,7 +5,7 @@ import { requirePin } from "$lib/auth";
import { db, g, s } from "$lib/db";
import { err, l, warn } from "$lib/logging";
import { mail, templates } from "$lib/mail";
-import { getProfile } from "$lib/nostr";
+import { getNostrUser, getProfile } from "$lib/nostr";
import { reconcile, types } from "$lib/payments";
import register from "$lib/register";
import { emit } from "$lib/sockets";
@@ -13,7 +13,7 @@ import upload from "$lib/upload";
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";
+import { randomBytes } from "@noble/hashes/utils";
import { $ } from "bun";
import jwt from "jsonwebtoken";
import { getPublicKey, nip19, verifyEvent } from "nostr-tools";
@@ -86,37 +86,7 @@ export default {
} catch (e) {}
}
- let user = await getUser(key);
-
- if (key.length === 64) {
- const nostr: any = await getProfile(key);
- if (nostr) {
- nostr.username = nostr.name || key.substr(0, 6);
- nostr.display = nostr.display_name || nostr.displayName;
- nostr.display_name = undefined;
- nostr.displayName = undefined;
- nostr.name = undefined;
- }
-
- if (user) {
- user.anon = false;
- nostr.display = undefined;
- }
-
- user = {
- ...nostr,
- currency: "USD",
- pubkey: key,
- anon: true,
- ...user,
- };
- }
-
- if (!user) return res.code(500).send("User not found");
-
- if (user.pubkey) user.npub = nip19.npubEncode(user.pubkey);
- user.prompt = !!user.prompt;
-
+ const user = await getNostrUser(key);
res.send(pick(user, fields));
} catch (e) {
err("problem getting user", e.message);