diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/db.ts | 6 | ||||
| -rw-r--r-- | lib/payments.ts | 6 |
2 files changed, 6 insertions, 6 deletions
@@ -6,12 +6,12 @@ import { warn, err } from "$lib/logging"; const DEBIT = ` local balanceKey = KEYS[1] local creditKey = KEYS[2] +local insufficientString = KEYS[3]; local amount = tonumber(ARGV[1]) local tip = tonumber(ARGV[2]) local fee = tonumber(ARGV[3]) local ourfee = tonumber(ARGV[4]) local frozen = tonumber(ARGV[5]) -local insufficientString = ARGV[6]; local balance = tonumber(redis.call('get', balanceKey) or '0') local credit = tonumber(redis.call('get', creditKey) or '0') @@ -20,7 +20,7 @@ local covered = math.min(credit, ourfee) ourfee = ourfee - covered if balance - frozen < amount + tip + fee + ourfee then - return {err = insufficientString .. '⚡️' .. balance - frozen .. ' / ' .. amount + tip + fee + ourfee} + return {err = insufficientString .. ' ⚡️' .. balance - frozen .. ' / ' .. amount + tip + fee + ourfee} end redis.call('decrby', creditKey, tostring(math.floor(covered))) @@ -55,7 +55,7 @@ end `; const debit = defineScript({ - NUMBER_OF_KEYS: 2, + NUMBER_OF_KEYS: 3, SCRIPT: DEBIT, transformArguments: (...args) => args.map((a) => a.toString()), }); diff --git a/lib/payments.ts b/lib/payments.ts index 38e8eab6..bc19dae9 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -120,17 +120,17 @@ export const debit = async ({ : 0; if (aid && aid !== uid) ourfee = 0; - const frozenBalance = await ga(`balance:${uid}`); + const frozenBalance = whitelisted ? 0 : await ga(`balance:${uid}`); ourfee = await db.debit( `balance:${aid || uid}`, `credit:${creditType}:${aid !== uid ? 0 : uid}`, + t(user).insufficientFunds, amount || 0, tip || 0, fee || 0, ourfee || 0, - frozenBalance, - t(user).insufficientFunds, + frozenBalance || 0, ); if (ourfee.err) fail(ourfee.err); |
