Merge pull request #1498 from stackernews/fix-1485

premature invoice deletion: fix interval in sql template
This commit is contained in:
Keyan 2024-10-19 09:52:16 -05:00 committed by GitHub
commit 7aa0d8f430
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -482,12 +482,12 @@ const resolvers = {
FROM "Withdrawl" FROM "Withdrawl"
WHERE "userId" = ${me.id} WHERE "userId" = ${me.id}
AND id = ${Number(id)} AND id = ${Number(id)}
AND now() > created_at + interval '${retention}' AND now() > created_at + ${retention}::INTERVAL
AND hash IS NOT NULL AND hash IS NOT NULL
AND status IS NOT NULL AND status IS NOT NULL
), updated_rows AS ( ), updated_rows AS (
UPDATE "Withdrawl" UPDATE "Withdrawl"
SET hash = NULL, bolt11 = NULL SET hash = NULL, bolt11 = NULL, preimage = NULL
FROM to_be_updated FROM to_be_updated
WHERE "Withdrawl".id = to_be_updated.id) WHERE "Withdrawl".id = to_be_updated.id)
SELECT * FROM to_be_updated;` SELECT * FROM to_be_updated;`
@ -499,7 +499,7 @@ const resolvers = {
console.error(error) console.error(error)
await models.withdrawl.update({ await models.withdrawl.update({
where: { id: invoice.id }, where: { id: invoice.id },
data: { hash: invoice.hash, bolt11: invoice.bolt11 } data: { hash: invoice.hash, bolt11: invoice.bolt11, preimage: invoice.preimage }
}) })
throw new GqlInputError('failed to drop bolt11 from lnd') throw new GqlInputError('failed to drop bolt11 from lnd')
} }

View File

@ -346,12 +346,12 @@ export async function autoDropBolt11s ({ models, lnd }) {
SELECT id, hash, bolt11 SELECT id, hash, bolt11
FROM "Withdrawl" FROM "Withdrawl"
WHERE "userId" IN (SELECT id FROM users WHERE "autoDropBolt11s") WHERE "userId" IN (SELECT id FROM users WHERE "autoDropBolt11s")
AND now() > created_at + interval '${retention}' AND now() > created_at + ${retention}::INTERVAL
AND hash IS NOT NULL AND hash IS NOT NULL
AND status IS NOT NULL AND status IS NOT NULL
), updated_rows AS ( ), updated_rows AS (
UPDATE "Withdrawl" UPDATE "Withdrawl"
SET hash = NULL, bolt11 = NULL SET hash = NULL, bolt11 = NULL, preimage = NULL
FROM to_be_updated FROM to_be_updated
WHERE "Withdrawl".id = to_be_updated.id) WHERE "Withdrawl".id = to_be_updated.id)
SELECT * FROM to_be_updated;` SELECT * FROM to_be_updated;`
@ -364,7 +364,7 @@ export async function autoDropBolt11s ({ models, lnd }) {
console.error(`Error removing invoice with hash ${invoice.hash}:`, error) console.error(`Error removing invoice with hash ${invoice.hash}:`, error)
await models.withdrawl.update({ await models.withdrawl.update({
where: { id: invoice.id }, where: { id: invoice.id },
data: { hash: invoice.hash, bolt11: invoice.bolt11 } data: { hash: invoice.hash, bolt11: invoice.bolt11, preimage: invoice.preimage }
}) })
} }
} }