teleton 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
MessageStore,
|
|
15
15
|
USED_TRANSACTIONS_SCHEMA,
|
|
16
16
|
UserStore,
|
|
17
|
+
closeDatabase,
|
|
17
18
|
createDbWrapper,
|
|
18
19
|
getDatabase,
|
|
19
20
|
initializeMemory,
|
|
@@ -10006,18 +10007,20 @@ function getDeal(db3, dealId) {
|
|
|
10006
10007
|
}
|
|
10007
10008
|
function acceptDeal(db3, dealId) {
|
|
10008
10009
|
const newExpiry = Math.floor(Date.now() / 1e3) + DEAL_VERIFICATION_WINDOW_SECONDS;
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10010
|
+
const r3 = db3.prepare(
|
|
10011
|
+
`UPDATE deals SET status = 'accepted', expires_at = ? WHERE id = ? AND status = 'proposed'`
|
|
10012
|
+
).run(newExpiry, dealId);
|
|
10013
|
+
return r3.changes === 1;
|
|
10013
10014
|
}
|
|
10014
10015
|
function declineDeal(db3, dealId) {
|
|
10015
|
-
db3.prepare(`UPDATE deals SET status = 'declined' WHERE id =
|
|
10016
|
+
const r3 = db3.prepare(`UPDATE deals SET status = 'declined' WHERE id = ? AND status = 'proposed'`).run(dealId);
|
|
10017
|
+
return r3.changes === 1;
|
|
10016
10018
|
}
|
|
10017
10019
|
function claimPayment(db3, dealId) {
|
|
10018
|
-
db3.prepare(
|
|
10019
|
-
`UPDATE deals SET status = 'payment_claimed', payment_claimed_at = unixepoch() WHERE id =
|
|
10020
|
+
const r3 = db3.prepare(
|
|
10021
|
+
`UPDATE deals SET status = 'payment_claimed', payment_claimed_at = unixepoch() WHERE id = ? AND status = 'accepted'`
|
|
10020
10022
|
).run(dealId);
|
|
10023
|
+
return r3.changes === 1;
|
|
10021
10024
|
}
|
|
10022
10025
|
function setInlineMessageId(db3, dealId, inlineMessageId) {
|
|
10023
10026
|
db3.prepare(`UPDATE deals SET inline_message_id = ? WHERE id = ?`).run(inlineMessageId, dealId);
|
|
@@ -10027,7 +10030,10 @@ function isDealExpired(deal) {
|
|
|
10027
10030
|
return now > deal.expiresAt;
|
|
10028
10031
|
}
|
|
10029
10032
|
function expireDeal(db3, dealId) {
|
|
10030
|
-
|
|
10033
|
+
const r3 = db3.prepare(
|
|
10034
|
+
`UPDATE deals SET status = 'expired' WHERE id = ? AND status IN ('proposed', 'accepted')`
|
|
10035
|
+
).run(dealId);
|
|
10036
|
+
return r3.changes === 1;
|
|
10031
10037
|
}
|
|
10032
10038
|
function getDealsAwaitingVerification(db3) {
|
|
10033
10039
|
const rows = db3.prepare(
|
|
@@ -11477,12 +11483,16 @@ var VerificationPoller = class {
|
|
|
11477
11483
|
* Handle verification timeout
|
|
11478
11484
|
*/
|
|
11479
11485
|
async handleTimeout(deal) {
|
|
11480
|
-
this.db.prepare(
|
|
11486
|
+
const r3 = this.db.prepare(
|
|
11481
11487
|
`UPDATE deals SET
|
|
11482
11488
|
status = 'failed',
|
|
11483
11489
|
notes = 'Payment verification timeout'
|
|
11484
|
-
WHERE id =
|
|
11490
|
+
WHERE id = ? AND status = 'payment_claimed'`
|
|
11485
11491
|
).run(deal.dealId);
|
|
11492
|
+
if (r3.changes !== 1) {
|
|
11493
|
+
this.retryMap.delete(deal.dealId);
|
|
11494
|
+
return;
|
|
11495
|
+
}
|
|
11486
11496
|
if (deal.inlineMessageId) {
|
|
11487
11497
|
const { text, buttons } = buildFailedMessage(
|
|
11488
11498
|
deal,
|
|
@@ -24281,6 +24291,7 @@ ${blue} \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
|
|
|
24281
24291
|
await mod.stop?.();
|
|
24282
24292
|
}
|
|
24283
24293
|
await this.bridge.disconnect();
|
|
24294
|
+
closeDatabase();
|
|
24284
24295
|
}
|
|
24285
24296
|
};
|
|
24286
24297
|
async function main(configPath) {
|
package/dist/cli/index.js
CHANGED
package/dist/index.js
CHANGED