From 10e1c15b5aad06782260505860d804511214dbb5 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 25 Oct 2022 21:24:21 +0000 Subject: rm log --- lib/send.js | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/send.js b/lib/send.js index f717d8f8..4f264509 100644 --- a/lib/send.js +++ b/lib/send.js @@ -68,7 +68,6 @@ export default async (amount, memo, hash, user) => { conversionFeeDeduction = Math.min(account.lightning_credits, conversionFee); total = amount + conversionFee - conversionFeeDeduction; - console.log("a t lc cf cfd", amount, total, account.lightning_credits, conversionFee, conversionFeeDeduction); if (!account || account.balance < total) { warn( -- cgit v1.2.3 From 75acb68fc7dddc4ce1547786908b8df168ec7fdf Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 26 Oct 2022 00:02:39 -0700 Subject: save recipient id with payment --- lib/sendInternal.js | 63 ++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'lib') diff --git a/lib/sendInternal.js b/lib/sendInternal.js index 2e98ed22..625fd42f 100644 --- a/lib/sendInternal.js +++ b/lib/sendInternal.js @@ -56,38 +56,10 @@ export default async ( await account.decrement({ balance: amount }, { transaction }); await account.reload({ transaction }); - let params = { - amount: -amount, - account_id: account.id, - memo, - user_id: user.id, - rate: store.rates[user.currency], - currency: user.currency, - confirmed: true, - hash: `#${v4().substr(0, 6)} ${ - username ? `Payment to ${username}` : "Internal Transfer" - }`, - network: "COINOS" - }; - - if (!username) { - l("creating redeemable payment"); - params.redeemcode = v4(); - params.hash = `${hostname}/redeem/${params.redeemcode}`; - } - - let payment = await db.Payment.create(params, { transaction }); - - payment = payment.get({ plain: true }); - payment.account = account.get({ plain: true }); - - l("sent internal", user.username, -payment.amount); - - emit(user.username, "payment", payment); - emit(user.username, "account", account); + let params, recipient; if (username) { - let recipient = await db.User.findOne( + recipient = await db.User.findOne( { where: { username }, include: { @@ -210,6 +182,37 @@ export default async ( callWebhook(invoice, p2); } + params = { + amount: -amount, + account_id: account.id, + memo, + user_id: user.id, + rate: store.rates[user.currency], + currency: user.currency, + confirmed: true, + with_id: recipient && recipient.id, + hash: `#${v4().substr(0, 6)} ${ + username ? `Payment to ${username}` : "Internal Transfer" + }`, + network: "COINOS" + }; + + if (!username) { + l("creating redeemable payment"); + params.redeemcode = v4(); + params.hash = `${hostname}/redeem/${params.redeemcode}`; + } + + let payment = await db.Payment.create(params, { transaction }); + + payment = payment.get({ plain: true }); + payment.account = account.get({ plain: true }); + + l("sent internal", user.username, -payment.amount); + + emit(user.username, "payment", payment); + emit(user.username, "account", account); + return payment; }); }; -- cgit v1.2.3 From 6c597132a7424317d2db33a11b6cff86c24875b1 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 26 Oct 2022 00:07:08 -0700 Subject: install deps in dev mode --- Dockerfile | 2 +- lib/sendInternal.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/Dockerfile b/Dockerfile index 80f6851c..a8a125ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,6 @@ RUN npm i -g pnpm COPY . /app WORKDIR /app -RUN NODE_OPTIONS="" pnpm i +RUN NODE_ENV=development NODE_OPTIONS="" pnpm i CMD ["pnpm", "start"] diff --git a/lib/sendInternal.js b/lib/sendInternal.js index 625fd42f..3090e94a 100644 --- a/lib/sendInternal.js +++ b/lib/sendInternal.js @@ -56,7 +56,7 @@ export default async ( await account.decrement({ balance: amount }, { transaction }); await account.reload({ transaction }); - let params, recipient; + let params, recipient, payment; if (username) { recipient = await db.User.findOne( @@ -203,7 +203,7 @@ export default async ( params.hash = `${hostname}/redeem/${params.redeemcode}`; } - let payment = await db.Payment.create(params, { transaction }); + payment = await db.Payment.create(params, { transaction }); payment = payment.get({ plain: true }); payment.account = account.get({ plain: true }); -- cgit v1.2.3