From 1d541fd97210389f006e65d46ab783afbe82cea8 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 26 Feb 2025 11:59:58 -0800 Subject: payment types --- lib/utils.ts | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) (limited to 'lib/utils.ts') 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; }; -- cgit v1.2.3