From 4c73bfdd4890bb8868a4c7cb5110cc98015a8318 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 14 Aug 2021 01:37:50 -0700 Subject: lookup invoice by text --- routes/send.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/routes/send.js b/routes/send.js index 3f240e85..9b4396ef 100644 --- a/routes/send.js +++ b/routes/send.js @@ -2,7 +2,15 @@ const axios = require("axios"); const uuidv4 = require("uuid/v4"); module.exports = ah(async (req, res, next) => { - let { amount, asset, memo, username } = req.body; + let { + amount, + address, + payreq, + unconfidential, + asset, + memo, + username, + } = req.body; let { user } = req; amount = parseInt(amount); @@ -74,9 +82,12 @@ module.exports = ah(async (req, res, next) => { { transaction } ); - let invoice = await db.Invoice.findOne({ - where: { amount, user_id: recipient.id }, - }); + let text = address || payreq; + params = { + where: { user_id: recipient.id }, + }; + if (text) params.where.text = text; + let invoice = await db.Invoice.findOne(params); let a2; let acc = { -- cgit v1.2.3