-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert JS to TS (commits 7-13 of PR435) - attempt#2 #585
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @webwarrior-ws @Mersho
When the admin goes to take a dispute this error appears in the logs:
[2024-09-04T10:09:59.680-04:00] error: Community was not found in DB Error: Community was not found in DB
at /home/catry/bot/bot/validations.js:208:27
at step (/home/catry/bot/bot/validations.js:56:23)
at Object.next (/home/catry/bot/bot/validations.js:37:53)
at fulfilled (/home/catry/bot/bot/validations.js:28:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also happened to me that the wizard_add_invoice_init
message was not being sent in any order even though it entered the wizard because any command or invoice that I sent to it would delete it. However, I stopped it and started it again and it worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When sending an invoice to receive, it always returns this error to the buyer: Invoice expiry is too short
fae0e71
to
e79a108
Compare
The bugs should be fixed now, but I haven't tested. |
Not sure about this one. Maybe it was because |
This error has already been solved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Al enviar una factura para recibir, siempre devuelve este error al comprador:
Invoice expiry is too short
@webwarrior-ws @Mersho That error is still there, it always says Invoice expiry is too short
but if I change to or any other branch and put the same invoice it accepts it without problem
I tried with my test setup and could not reproduce this bug. |
@grunch could you try to reproduce it? I can't get that error not to appear, thanks :) |
Added some debug logging. Maybe that will help with identifying the problem. |
Well, the bot did not show the But I knew it was 500 sats so I put the invoice and this appears:
|
I don't see any bug in lnp2pBot code here. Invoice expires less than |
Looks like we need @grunch's input here? |
Hi guys! I'm testing it, after I take a dispute of an order created in the global channel is works perfectly, after I take a dispute of an order created on a community it doesn't work, here the log
|
@grunch I have tried to reproduce the bug, but I can't take a dispute - when I click on "Take dispute" button I get a message "You have been banned!". As I only have 2 telegram accounts, solver user is one of the participants, maybe that's the issue? |
1e1d276
to
74a60e2
Compare
Me and @knocte managed to take and resolve dispute in community. That error looks like contents of some variable is not escaped properly. I've seen a commit in |
Yes, we ban users after being involved on n disputes, I think that restriction is not useful and we should remove it in the future, but to continue just remove the ban on the document for that user, change field |
Francisco, that is old info. After webwarrior wrote that message, I assisted him in his testing, being the 3rd user in his setup (the solver, in particular), and he couldn't reproduce the issue. See #585 (comment) , and test again with the new logs added please. |
Hi @webwarrior-ws sorry for the delay, are you able to run the bot in this branch? I'm testing and I'm getting this errors
I that we are having conflics, can you solve them and we can try again? |
The languageModel & fiatModel interface created to type-check the data and ensure that it conforms to the expected structure and format. This can help you avoid errors and bugs when working with the data in your code. This commit enables resolveJsonModule to import module with '.json' extension. Co-authored-by: webwarrior <[email protected]>
The --downlevelIteration flag is a TypeScript compiler option that enables support for iterating over new concepts like Map, Set, or Generator in older JavaScript runtimes. By default, TypeScript targets ES3, which does not support these features. If you use a for...of loop or a spread operator on an iterable object, you may get an error. Use Date instead of Date.toISOString cause paid_at has type Date and during the conversion from js to ts, we got compilation errors. Co-authored-by: webwarrior <[email protected]>
Co-authored-by: webwarrior <[email protected]>
Using null instead of a boolean/undefined type is better.
I had to change the '|', otherwise typescript would complain this error msg: ``` The '|' operator is not allowed for boolean types. Consider using '||' instead. ``` Co-authored-by: webwarrior <[email protected]>
Fix bugs in validations.ts introduced in d36a6b7 when porting to TypeScript.
Fixed bug in validateAdmin that would throw an error when community is null even though null value is valid in this case.
Don't convert dates to strings in isValidInvoice.
Added debug logging for case when `Invoice expiry is too short` error is encountered.
Added debug logging of message that caused error when taking dispute in community.
867151c
to
2ee0fce
Compare
@grunch I've rebased PR branch and there are no merge conflicts now. I've also tested it with standard sell/buy procedure and got no 503 errors that you have mentioned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for solving the conflicts, I just tested it again and I found a new bug, here the log:
[2024-09-24T14:56:16.092-03:00] error: 400: Bad Request: can't parse entities: Character '.' is reserved and must be escaped with the preceding '\' Error: 400: Bad Request: can't parse entities: Character '.' is reserved and must be escaped with the preceding '\'
at Telegram.callApi (/home/grunch/dev/bot-warrior/node_modules/telegraf/lib/core/network/client.js:315:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async exports.disputeData (/home/grunch/dev/bot-warrior/bot/modules/dispute/messages.js:114:5)
I dig in a bit and I found that you can't use object properties inside locales, so I changed, here the patch, can you apply this on the other languages? thanks
diff --git a/bot/modules/dispute/messages.js b/bot/modules/dispute/messages.js
index a887012..d8bc775 100644
--- a/bot/modules/dispute/messages.js
+++ b/bot/modules/dispute/messages.js
@@ -1,4 +1,8 @@
-const { getDisputeChannel, getDetailedOrder, sanitizeMD } = require('../../../util');
+const {
+ getDisputeChannel,
+ getDetailedOrder,
+ sanitizeMD,
+} = require('../../../util');
const { logger } = require('../../../logger');
exports.beginDispute = async (ctx, initiator, order, buyer, seller) => {
@@ -91,11 +95,11 @@ exports.disputeData = async (
// Fix Issue 543: Escape underscores in usernames
const escapedInitiatorUsername = sanitizeMD(initiatorUser.username);
const escapedCounterPartyUsername = sanitizeMD(counterPartyUser.username);
-
+
const message = ctx.i18n.t('dispute_started_channel', {
- initiatorUser: { ...initiatorUser, username: escapedInitiatorUsername },
+ initiatorUser: escapedInitiatorUsername,
initiatorTgId: initiatorUser.tg_id,
- counterPartyUser: { ...counterPartyUser, username: escapedCounterPartyUsername },
+ counterPartyUser: escapedCounterPartyUsername,
counterPartyUserTgId: counterPartyUser.tg_id,
buyer,
seller,
@@ -107,11 +111,9 @@ exports.disputeData = async (
buyerToken: order.buyer_dispute_token,
});
console.log(`Contens of message:\n${message}`);
- await ctx.telegram.sendMessage(
- solver.tg_id,
- message,
- { parse_mode: 'MarkdownV2' }
- );
+ await ctx.telegram.sendMessage(solver.tg_id, message, {
+ parse_mode: 'MarkdownV2',
+ });
// message to both parties letting them know the dispute
// has been taken by a solver
await ctx.telegram.sendMessage(
diff --git a/locales/es.yaml b/locales/es.yaml
index 9baf03f..26cbc22 100644
--- a/locales/es.yaml
+++ b/locales/es.yaml
@@ -202,16 +202,16 @@ order_detail: |
seller: vendedor
buyer: comprador
dispute_started_channel: |
- El ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
- ha iniciado una disputa con @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} en la orden:
+ El ${type} @${initiatorUser} TG ID: ${initiatorTgId}
+ ha iniciado una disputa con @${counterPartyUser} TG ID: ${counterPartyUserTgId} en la orden:
${detailedOrder}
Seller Token: ${sellerToken}
Buyer Token: ${buyerToken}
- @${initiatorUser.username} ya tiene ${buyerDisputes} disputas
- @${counterPartyUser.username} ya tiene ${sellerDisputes} disputas
+ @${initiatorUser} ya tiene ${buyerDisputes} disputas
+ @${counterPartyUser} ya tiene ${sellerDisputes} disputas
you_started: '🥴 Has iniciado una disputa en tu orden con Id: ${orderId}.'
counterpart_started: '🥴 Tu contraparte ha iniciado una disputa en tu orden con Id: ${orderId}.'
dispute_started: '${who} Un solver te atenderá pronto, cuando él/la solver sea asignado a tu disputa el bot te dirá su username, solo él/ella podrá atenderte. Puedes escribirle directamente, pero si él/ella te contacta primero, debes pedirle que te diga cuál es el token de tu disputa, tu token es: ${token}.'
diff --git a/util/index.ts b/util/index.ts
index 0b1bc7e..902d9e4 100644
--- a/util/index.ts
+++ b/util/index.ts
@@ -368,7 +368,7 @@ const getDetailedOrder = (i18n: I18nContext, order: IOrder, buyer: UserDocument,
takenAt = sanitizeMD(takenAt);
const previousDisputeStatus = sanitizeMD(order.previous_dispute_status);
const status = sanitizeMD(order.status);
- const fee = order.fee ? Number(order.fee) : '';
+ const fee = order.fee ? sanitizeMD(Number(order.fee)) : '';
const creator =
order.creator_id === buyerId ? buyerUsername : sellerUsername;
const buyerAge = buyer? getUserAge(buyer) : '';
Don't use object properties inside locales, as it doesn't work and leads to parse errors.
ede5ef3
to
706b9fd
Compare
@grunch applied your patch, updated locales and disputes test |
great job, thanks for this contribution, as we are receiving some donations we want to give back some sats to our contributors, it's more of a symbolic gesture of gratitude 😃 Please add as a comment a lightning invoice with amount of 200,000 sats |
lnbc2m1pn0dtz0pp5ru28d55mfjw2aypjvsu7xnd5uj7363mz095slnwmca05mcequ9nscqpjsp5vuprh07ze5nk2k6rhx7zjy67axfqmsej9gmt6a7zudhsy7ej8zas9q7sqqqqqqqqqqqqqqqqqqqsqqqqqysgqdqqmqz9gxqyjw5qrzjqwryaup9lh50kkranzgcdnn2fgvx390wgj5jd07rwr3vxeje0glcll6lyxlsu4fuhqqqqqlgqqqqqeqqjqu7s52ap9967fnyvqc9nphcccsqpl3txa679zpzw2f0h6gwqhex7qwf5y2eywlmd5wyjx9e7k5ckn2luml34c304mtyuze87zy5mkfdgpmqngrw |
Payment hash: 1f1476d29b4c9cae90326439e34db4e4bd1d476279690fcddbc75f4de320e167 |
Supersedes #557. Added a commit that should fix bug in disputes.