diff options
| -rw-r--r-- | lib/sockets.js | 4 | ||||
| -rw-r--r-- | lib/webhooks.js | 6 | ||||
| -rw-r--r-- | routes/send.js | 2 | ||||
| -rw-r--r-- | routes/users.js | 16 |
4 files changed, 22 insertions, 6 deletions
diff --git a/lib/sockets.js b/lib/sockets.js index 8cdb7992..9220d420 100644 --- a/lib/sockets.js +++ b/lib/sockets.js @@ -16,16 +16,18 @@ const lastSeen = {}; emit = (username, type, data) => { if (data.username !== undefined) data = pick(data, ...whitelist); + if (type === "payment" && data.amount > 0) { for (let i = subscriptions.length - 1; i >= 0; i--) { let s = subscriptions[i]; + if ( s.invoice.amount === data.amount || (data.address && s.invoice.address === data.address) || (data.address && s.invoice.unconfidential === data.address) ) { s.ws.send(JSON.stringify({ type, data })); - subscriptions.splice(i, 1); + // subscriptions.splice(i, 1); } } } diff --git a/lib/webhooks.js b/lib/webhooks.js index c282ceea..2dbdf7c1 100644 --- a/lib/webhooks.js +++ b/lib/webhooks.js @@ -24,9 +24,7 @@ callWebhook = (invoice, payment) => { memo, confirmed, text, - webhook, - }) - .json() - .catch(console.log); + webhook + }).res().catch(console.log); } }; diff --git a/routes/send.js b/routes/send.js index 653da87b..0c93d0a2 100644 --- a/routes/send.js +++ b/routes/send.js @@ -99,7 +99,7 @@ module.exports = ah(async (req, res, next) => { }; if (address) params.where.address = address; else if (payreq) params.where.text = payreq; - let invoice = await db.Invoice.findOne(params); + let invoice = (address || payreq) && await db.Invoice.findOne(params); let a2; let acc = { diff --git a/routes/users.js b/routes/users.js index ef220a32..bcce9c14 100644 --- a/routes/users.js +++ b/routes/users.js @@ -32,7 +32,23 @@ app.get( auth, ah(async (req, res) => { let user = req.user.get({ plain: true }); + let payments = await req.user.getPayments({ + where: { + account_id: user.account_id + }, + order: [["id", "DESC"]], + limit: 12, + include: [{ + model: db.Account, + as: "account" + }, + { + model: db.Payment, + as: "fee_payment" + }] + }); user.accounts = await req.user.getAccounts(); + user.payments = payments; res.send(user); }) ); |
