diff options
| author | Adam Soltys <[email protected]> | 2025-02-26 11:59:58 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-26 11:59:58 -0800 |
| commit | 1d541fd97210389f006e65d46ab783afbe82cea8 (patch) | |
| tree | 66781ea2992fa99198ed1e450cdb9b68acfbc4d9 /lib/utils.ts | |
| parent | a14b987a392bc700975b048f37838da08e4ed255 (diff) | |
| download | coinos-server-1d541fd97210389f006e65d46ab783afbe82cea8.tar.gz coinos-server-1d541fd97210389f006e65d46ab783afbe82cea8.zip | |
payment types
Diffstat (limited to 'lib/utils.ts')
| -rw-r--r-- | lib/utils.ts | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/lib/utils.ts b/lib/utils.ts index 79b95e62..018dc92e 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,9 +1,6 @@ import config from "$config"; -import { g, s } from "$lib/db"; +import { g } from "$lib/db"; import locales from "$lib/locales/index"; -import migrate from "$lib/migrate"; -import { bytesToHex, randomBytes } from "@noble/hashes/utils"; -import { getPublicKey } from "nostr"; const { URL } = process.env; @@ -51,32 +48,10 @@ export const bip21 = (address, { amount, memo, tip, type }) => { }; export const getUser = async (username, fields = undefined) => { - let update; if (username === "undefined") fail("invalid user"); - const user = await migrate(username); - if (user && !user.anon && !user.nwc) { - user.nwc = bytesToHex(randomBytes(32)); - await s(getPublicKey(user.nwc), user.id); - update = true; - } - - if (user?.profile) { - user.picture = `https://coinos.io/api/public/${user.profile}.webp`; - delete user.profile; - - if (user.banner) { - user.banner = `https://coinos.io/api/public/${user.banner}.webp`; - } - update = true; - } - - if (user?.address) { - user.about = user.address; - delete user.address; - update = true; - } - - if (update) s(`user:${user.id}`, user); + const k = username?.replace(/\s/g, "").toLowerCase(); + let user = await g(`user:${k}`); + if (typeof user === "string") user = await g(`user:${user}`); return fields && user ? pick(user, fields) : user; }; |
