aboutsummaryrefslogtreecommitdiffstats
path: root/routes/payments.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-06-08 13:04:02 -0700
committerAdam Soltys <[email protected]>2020-06-08 13:04:02 -0700
commit7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2 (patch)
treeb31a06affa4b932990744997c271f6d65502d60c /routes/payments.js
parent298672d3f50938ba06a16f8e04d607b7033703b8 (diff)
downloadcoinos-server-7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2.tar.gz
coinos-server-7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2.zip
reduce network traffic
Diffstat (limited to 'routes/payments.js')
-rw-r--r--routes/payments.js35
1 files changed, 17 insertions, 18 deletions
diff --git a/routes/payments.js b/routes/payments.js
index db40c73e..8f731f78 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -15,18 +15,20 @@ const { join } = require("path");
if (u.liquid) addresses[u.liquid] = u.username;
});
- payments = (await db.Payment.findAll({
- attributes: ["hash"]
- })).map(p => p.hash);
+ payments = (
+ await db.Payment.findAll({
+ attributes: ["hash"]
+ })
+ ).map(p => p.hash);
app.post("/send", auth, require("./send"));
if (config.lna) {
if (config.lna.clightning) {
- const lnapath = join(require('os').homedir(), '.lightningreg/regtest')
- const lnbpath = join(require('os').homedir(), '.lightningregb/regtest')
- lna = require('clightning-client')(lnapath);
- lnb = require('clightning-client')(lnbpath);
+ const lnapath = join(require("os").homedir(), ".lightningreg/regtest");
+ const lnbpath = join(require("os").homedir(), ".lightningregb/regtest");
+ lna = require("clightning-client")(lnapath);
+ lnb = require("clightning-client")(lnbpath);
} else {
lna = lnd(config.lna);
lnb = lnd(config.lnb);
@@ -56,20 +58,17 @@ const { join } = require("path");
}
app.get("/payments", auth, async (req, res) => {
- const payments = await db.Payment.findAll({
- where: {
- user_id: req.user.id,
- [Op.or]: {
- received: true,
- amount: {
- [Op.lt]: 0,
- },
- },
+ let payments = await req.user.getPayments({
+ where: {
+ account_id: req.user.account_id
},
- order: [["id", "DESC"]]
+ order: [["id", "DESC"]],
+ include: {
+ model: db.Account,
+ as: "account"
+ }
});
- emit(req.user.username, "payments", payments);
res.send(payments);
});
})();