mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
refactor: simplify deletion of expired quote ids expiredQuoteIds
This commit is contained in:
parent
0a05dd232c
commit
6afa0bb7f1
1 changed files with 6 additions and 4 deletions
|
|
@ -97,7 +97,12 @@ route.post('/mint/:quote_id', userMiddleware({ enc: 'nip44' }), async (c) => {
|
|||
const now = nostrNow();
|
||||
|
||||
try {
|
||||
if (mintUrl && (expiration > now) && (quote_id === decryptedQuoteId)) { // TODO: organize order of operations of deleting expired quote ids
|
||||
if (mintUrl && (quote_id === decryptedQuoteId)) {
|
||||
if (expiration <= now) {
|
||||
expiredQuoteIds.push(event.id);
|
||||
continue;
|
||||
}
|
||||
|
||||
const mint = new CashuMint(mintUrl);
|
||||
const wallet = new CashuWallet(mint);
|
||||
await wallet.loadMint();
|
||||
|
|
@ -131,7 +136,6 @@ route.post('/mint/:quote_id', userMiddleware({ enc: 'nip44' }), async (c) => {
|
|||
),
|
||||
}, c);
|
||||
|
||||
expiredQuoteIds.push(event.id);
|
||||
await deleteExpiredQuotes(expiredQuoteIds);
|
||||
|
||||
return c.json({ success: 'Minting successful!', state: MintQuoteState.ISSUED }, 200);
|
||||
|
|
@ -145,8 +149,6 @@ route.post('/mint/:quote_id', userMiddleware({ enc: 'nip44' }), async (c) => {
|
|||
logi({ level: 'error', ns: 'ditto.api.cashu.mint', error: errorJson(e) });
|
||||
return c.json({ error: 'Server error' }, 500);
|
||||
}
|
||||
|
||||
expiredQuoteIds.push(event.id);
|
||||
}
|
||||
|
||||
await deleteExpiredQuotes(expiredQuoteIds);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue