diff options
| author | Adam Soltys <[email protected]> | 2022-10-06 02:58:18 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-10-06 02:58:18 -0700 |
| commit | 28179d6b58df35bc31c72463cbd029db9d162baf (patch) | |
| tree | 67a286c993860a59ba9580a89402b1383ef6957b /routes | |
| parent | 12fcb358b14e0754457d79e9103e46c6426218a8 (diff) | |
| download | coinos-server-28179d6b58df35bc31c72463cbd029db9d162baf.tar.gz coinos-server-28179d6b58df35bc31c72463cbd029db9d162baf.zip | |
handle invoice lookup by uuid
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/invoices.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/routes/invoices.js b/routes/invoices.js index f843d663..14efdf2a 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -32,10 +32,17 @@ app.get("/invoice", async (req, res, next) => { app.get("/invoice/:text", async (req, res, next) => { try { let { text } = req.params; + let where = + text.split("-").length > 4 + ? { uuid: text } + : text.startsWith("ln") + ? { text } + : { + [Op.or]: [{ unconfidential: text }, { address: text }] + }; + const invoice = await db.Invoice.findOne({ - where: { - [Op.or]: [{ unconfidential: text }, { address: text }, { text }] - }, + where, include: { model: db.User, as: "user", |
