diff options
| author | Adam Soltys <[email protected]> | 2023-03-21 00:06:39 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-03-21 00:06:39 -0700 |
| commit | 469c384e0930dd2b7c0f01c03cca95f86f05277d (patch) | |
| tree | 17b24286259596987e74913d72e4733ec58c4f1d /routes | |
| parent | c99665a0a0ac79176726169a49d5f9ebaae325bc (diff) | |
| download | coinos-server-469c384e0930dd2b7c0f01c03cca95f86f05277d.tar.gz coinos-server-469c384e0930dd2b7c0f01c03cca95f86f05277d.zip | |
ses mail
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/email.js | 45 | ||||
| -rw-r--r-- | routes/payments.js | 17 |
2 files changed, 35 insertions, 27 deletions
diff --git a/routes/email.js b/routes/email.js index 1b551864..1f7ce4a0 100644 --- a/routes/email.js +++ b/routes/email.js @@ -1,7 +1,8 @@ import { bail } from "$lib/utils"; import got from "got"; import config from "$config"; -import sendgrid from "@sendgrid/mail"; +import { SESClient, CloneReceiptRuleSetCommand } from "@aws-sdk/client-ses"; +import { SendEmailCommand } from "@aws-sdk/client-ses"; export default { async send({ body }, res) { @@ -11,26 +12,44 @@ export default { .post("https://www.google.com/recaptcha/api/siteverify", { form: { secret, - response, - }, + response + } }) .json(); if (success) { delete body.token; - sendgrid.setApiKey(config.sendgrid); - const msg = { - to: "[email protected]", - from: "[email protected]", - subject: body.subject || "Email Signup", - text: JSON.stringify(body), - html: JSON.stringify(body), - }; - await sendgrid.send(msg); + let client = new SESClient({ region: "us-east-2" }); + await client.send( + new SendEmailCommand({ + Destination: { + CcAddresses: [], + ToAddresses: ["[email protected]"] + }, + Message: { + Body: { + Html: { + Charset: "UTF-8", + Data: JSON.stringify(body) + }, + Text: { + Charset: "UTF-8", + Data: JSON.stringify(body) + } + }, + Subject: { + Charset: "UTF-8", + Data: body.subject || "Email Signup" + } + }, + Source: "[email protected]" + }) + ); + res.send({ ok: true }); } else { bail(res, "failed captcha"); } - }, + } }; diff --git a/routes/payments.js b/routes/payments.js index 1a5bcf76..3c318f2d 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -404,22 +404,11 @@ export default { async fix({ body: { uid, username }, user }, res) { try { if (!user.admin) fail("unauthorized"); - - if (username) uid = await g(`user:${username.toLowerCase()}`); - ({ username } = await g(`user:${uid}`)); - let balance = await g(`balance:${uid}`); - - let payments = await db.lRange(`${uid}:payments`, 0, -1); - - let total = 0; - for (let pid of payments) { - let p = await g(`payment:${pid}`); - total += p.amount; - if (p.amount < 0) total -= (p.fee || 0) + (p.ourfee || 0); + for await (let k of db.scanIterator({ MATCH: "balance:*" })) { + let bal = await g(k); + if (bal < 0) s(k, 0); } - l("corrected balance", username, uid, balance, total); - await s(`balance:${uid}`, total); res.send("ok"); } catch (e) { console.log(e); |
