aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-08 20:13:48 -0700
committerAdam Soltys <[email protected]>2024-10-10 12:17:05 -0700
commit0a2734dfb5ae312f5283f93ab2e3f819ace3f94b (patch)
tree9170fc9bb3c7e9bb5b05ccea407321eb6c7302ef /routes/users.ts
parent372c635714f6e7de8a0da135980697b49f207f2c (diff)
downloadcoinos-server-0a2734dfb5ae312f5283f93ab2e3f819ace3f94b.tar.gz
coinos-server-0a2734dfb5ae312f5283f93ab2e3f819ace3f94b.zip
nostr revamp wip
Diffstat (limited to 'routes/users.ts')
-rw-r--r--routes/users.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/routes/users.ts b/routes/users.ts
index 18ef7e3b..f907340e 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -15,7 +15,7 @@ import { mail, templates } from "$lib/mail";
import upload from "$lib/upload";
import rpc from "@coinos/rpc";
import { nip19 } from "nostr-tools";
-import { hex } from "@scure/base";
+import { getProfile } from "$lib/nostr";
export default {
upload,
@@ -78,19 +78,27 @@ export default {
try {
if (key.startsWith("npub")) {
try {
- key = hex.encode(nip19.decode(key).data as Uint8Array);
+ key = nip19.decode(key).data;
} catch (e) {}
}
let user = await getUser(key);
- if (!user && key.length === 64) {
+ if (key.length === 64) {
+ let nostr: any = await getProfile(key);
+ if (nostr) {
+ nostr.username = nostr.name;
+ nostr.display = nostr.display_name || nostr.displayName;
+ }
+
+ if (user) user.anon = false;
+
user = {
+ ...nostr,
currency: "USD",
- username: key,
- display: key.substr(0, 6),
pubkey: key,
anon: true,
+ ...user,
};
}
@@ -105,8 +113,10 @@ export default {
"display",
"id",
"hidepay",
+ "lud16",
"memoPrompt",
"npub",
+ "picture",
"profile",
"prompt",
"pubkey",