diff options
| author | Adam Soltys <[email protected]> | 2023-12-29 01:31:05 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-12-29 01:31:05 -0800 |
| commit | 46522875683db9123f8a6fe9746a5c5db6f1638e (patch) | |
| tree | a8d3804065319df7f1338e39d5a954a0c41150ef | |
| parent | f584d7a56762d19ac6c1f5eda87cfb26816d5d57 (diff) | |
| download | coinos-server-46522875683db9123f8a6fe9746a5c5db6f1638e.tar.gz coinos-server-46522875683db9123f8a6fe9746a5c5db6f1638e.zip | |
username casing
| -rw-r--r-- | lib/migrate.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/migrate.js b/lib/migrate.js index a523fb27..20d26325 100644 --- a/lib/migrate.js +++ b/lib/migrate.js @@ -4,6 +4,7 @@ import { archive, db, g } from "$lib/db"; let q = {}; async function migrate(id) { + id = id.replace(/\s/g, "").toLowerCase(); let user = JSON.parse(await archive.get(`user:${id}`)); if (typeof user === "string") { @@ -12,19 +13,21 @@ async function migrate(id) { } if (user) { + let { username } = user; + username = username.replace(/\s/g, "").toLowerCase(); let multi = await db .multi() - .set(`user:${user.username}`, id) + .set(`user:${username}`, id) .set(`user:${user.pubkey}`, id) .set(`user:${id}`, JSON.stringify(user)) .set(`${id}:contacts`, (await archive.get(`${id}:contacts`)) || "[]") .set( `credit:bitcoin:${id}`, - (await archive.get(`credit:bitcoin:${id}`)) || 0 + (await archive.get(`credit:bitcoin:${id}`)) || 0, ) .set( `credit:lightning:${id}`, - (await archive.get(`credit:lightning:${id}`)) || 0 + (await archive.get(`credit:lightning:${id}`)) || 0, ) .set(`${id}:lastlen`, (await archive.get(`${id}:lastlen`)) || 0) .set(`${id}:cindex`, (await archive.get(`${id}:cindex`)) || 0) @@ -43,7 +46,7 @@ async function migrate(id) { multi = await multi .lPush(`${id}:payments`, pid) .set(`payment:${pid}`, JSON.stringify(p)); - }) + }), ); let invoices = await archive.lRange(`${id}:invoices`, 0, -1); @@ -53,13 +56,15 @@ async function migrate(id) { multi = await multi .lPush(`${id}:invoices`, iid) .set(`invoice:${iid}`, inv); - }) + }), ); await multi.exec(); delete q[id]; + console.log("SUCCESS", username); + return user; } } |
