From 417f669783b275d21382e80eb4c8e793a09666a8 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 15 Nov 2023 23:34:24 -0800 Subject: fix images --- routes/payments.js | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/routes/payments.js b/routes/payments.js index e8f9888e..416f4510 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -39,7 +39,7 @@ export default { let { amount, hash, maxfee, fund, memo, payreq, username } = body; try { - if (await g('freeze')) fail("Problem sending payment"); + if (await g("freeze")) fail("Problem sending payment"); amount = parseInt(amount); if (amount < 0) fail("Invalid amount"); @@ -513,11 +513,40 @@ export default { async fix({ body: { uid, username }, user }, res) { try { if (!user.admin) fail("unauthorized"); + for await (let k of db.scanIterator({ MATCH: "balance:*" })) { let bal = await g(k); if (bal < 0) s(k, 0); } + for await (let k of db.scanIterator({ MATCH: "user:*" })) { + let u = await g(k); + let id = k.split(":")[1]; + + if (typeof u === "String") { + id = u; + u = await g(`user:${u}`); + } + + if (!(u && u.username)) continue; + + let touched; + + console.log(u.username, u.profile, u.banner); + + if (u.profile) { + u.profile = `${u.id}-profile`; + touched = true; + } + + if (u.banner) { + u.banner = `${u.id}-banner`; + touched = true; + } + + if (touched) await s(`user:${u.id}`, u); + } + res.send("ok"); } catch (e) { console.log(e); @@ -525,10 +554,10 @@ export default { } }, - async freeze({ body: { secret }}, res) { + async freeze({ body: { secret } }, res) { try { if (secret !== config.adminpass) fail("unauthorized"); - await s('freeze', true); + await s("freeze", true); res.send("ok"); } catch (e) { console.log(e); -- cgit v1.2.3