aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/query.js
blob: 1c217a08aeef4a05364c8509c22efed2df85da06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import db from "$db";
import { emit } from "$lib/sockets";

export default async (req, res) => {
  const { payreq } = req.body;

  const invoice = await db.Invoice.findOne({
    include: {
      attributes: ["username"],
      model: db.User,
      as: "user"
    },
    where: {
      text: payreq
    }
  });

  if (invoice) emit(req.user.username, "to", invoice.user);
  res.send({});
};