diff options
| author | Adam Soltys <[email protected]> | 2024-10-17 11:34:53 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-17 11:34:53 -0700 |
| commit | dd52d07a513c4c98197b36eb48e213a0b2164d32 (patch) | |
| tree | 645a4a185585093c4ce8b61e9e4cad126226bdb5 | |
| parent | 70d752642c7faa786f45e90c2afaf348efe4310d (diff) | |
| download | coinos-server-dd52d07a513c4c98197b36eb48e213a0b2164d32.tar.gz coinos-server-dd52d07a513c4c98197b36eb48e213a0b2164d32.zip | |
rm payment from list
| -rw-r--r-- | lib/db.ts | 7 | ||||
| -rw-r--r-- | lib/payments.ts | 2 | ||||
| -rw-r--r-- | routes/payments.ts | 1 |
3 files changed, 8 insertions, 2 deletions
@@ -32,6 +32,8 @@ local paymentKey = KEYS[1] local balanceKey = KEYS[2] local creditKey = KEYS[3] local hashKey = KEYS[4] +local paymentsKey = KEYS[5] +local pid = KEYS[6] local total = tonumber(ARGV[1]) local credit = tonumber(ARGV[2]) @@ -43,9 +45,10 @@ if payment ~= nil then redis.call('incrby', creditKey, credit) redis.call('del', paymentKey) redis.call('del', hashKey) + redis.call('lrem', paymentsKey, 0, pid); end -return paymentKey +return pid `; let debit = defineScript({ @@ -55,7 +58,7 @@ let debit = defineScript({ }); let reverse = defineScript({ - NUMBER_OF_KEYS: 4, + NUMBER_OF_KEYS: 6, SCRIPT: REVERSE, transformArguments: (...args) => args.map((a) => a.toString()), }); diff --git a/lib/payments.ts b/lib/payments.ts index 1f1497ec..cc55e5ce 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -818,6 +818,8 @@ let reverse = async (p) => { `balance:${p.uid}`, `credit:${types.lightning}:${p.uid}`, `payment:${p.hash}`, + `${p.uid}:payments`, + p.id, total, credit, ); diff --git a/routes/payments.ts b/routes/payments.ts index 5eb802bc..33f66e8d 100644 --- a/routes/payments.ts +++ b/routes/payments.ts @@ -95,6 +95,7 @@ export default { let p = await g(`payment:${pid}`); if (!p) { warn("user", id, "missing payment", pid); + await db.lRem(`${aid || id}:payments`, 0, pid); return p; } if (p.created < start || p.created > end) return; |
