Skip to content

Commit 706b9fd

Browse files
committed
bot,util,locales,tests: don't use objects in locales
Don't use object properties inside locales, as it doesn't work and leads to parse errors.
1 parent ba09fdd commit 706b9fd

File tree

13 files changed

+56
-54
lines changed

13 files changed

+56
-54
lines changed

Diff for: bot/modules/dispute/messages.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
const { getDisputeChannel, getDetailedOrder, sanitizeMD } = require('../../../util');
1+
const {
2+
getDisputeChannel,
3+
getDetailedOrder,
4+
sanitizeMD,
5+
} = require('../../../util');
26
const { logger } = require('../../../logger');
37

48
exports.beginDispute = async (ctx, initiator, order, buyer, seller) => {
@@ -91,11 +95,11 @@ exports.disputeData = async (
9195
// Fix Issue 543: Escape underscores in usernames
9296
const escapedInitiatorUsername = sanitizeMD(initiatorUser.username);
9397
const escapedCounterPartyUsername = sanitizeMD(counterPartyUser.username);
94-
98+
9599
const message = ctx.i18n.t('dispute_started_channel', {
96-
initiatorUser: { ...initiatorUser, username: escapedInitiatorUsername },
100+
initiatorUser: escapedInitiatorUsername,
97101
initiatorTgId: initiatorUser.tg_id,
98-
counterPartyUser: { ...counterPartyUser, username: escapedCounterPartyUsername },
102+
counterPartyUser: escapedCounterPartyUsername,
99103
counterPartyUserTgId: counterPartyUser.tg_id,
100104
buyer,
101105
seller,
@@ -107,11 +111,9 @@ exports.disputeData = async (
107111
buyerToken: order.buyer_dispute_token,
108112
});
109113
console.log(`Contens of message:\n${message}`);
110-
await ctx.telegram.sendMessage(
111-
solver.tg_id,
112-
message,
113-
{ parse_mode: 'MarkdownV2' }
114-
);
114+
await ctx.telegram.sendMessage(solver.tg_id, message, {
115+
parse_mode: 'MarkdownV2',
116+
});
115117
// message to both parties letting them know the dispute
116118
// has been taken by a solver
117119
await ctx.telegram.sendMessage(

Diff for: locales/de.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,16 @@ order_detail: |
202202
seller: Käufer
203203
buyer: Verkäufer
204204
dispute_started_channel: |
205-
Benutzer ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
206-
hat einen Streitfall mit @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} für den folgenden Auftrag eröffnet
205+
Benutzer ${type} @${initiatorUser} TG ID: ${initiatorTgId}
206+
hat einen Streitfall mit @${counterPartyUser} TG ID: ${counterPartyUserTgId} für den folgenden Auftrag eröffnet
207207
208208
${detailedOrder}
209209
210210
Seller Token: ${sellerToken}
211211
Buyer Token: ${buyerToken}
212212
213-
@${initiatorUser.username} war an ${initiatorUser.disputes} Streitfällen beteiligt
214-
@${counterPartyUser.username} war an ${counterPartyUser.disputes} Streitfällen beteiligt
213+
@${initiatorUser} war an ${buyerDisputes} Streitfällen beteiligt
214+
@${counterPartyUser} war an ${sellerDisputes} Streitfällen beteiligt
215215
you_started: '🥴 Sie haben einen Streitfall zu Ihrer Bestellnummer begonnen: ${orderId}.'
216216
counterpart_started: '🥴 Ihre Gegenpartei hat einen Streit über Ihre Bestellungsnummer begonnen: ${orderId}.'
217217
dispute_started: '${who} Wenn er/sie Ihrem Streitfall zugewiesen wird, teilt der Bot Ihnen seinen/ihren Benutzernamen mit, und nur er/sie kann Sie betreuen. Sie können ihm/ihr direkt schreiben, aber wenn er/sie Sie zuerst kontaktiert, müssen Sie ihn/sie bitten, Ihnen den Token Ihres Streitfalls mitzuteilen, Ihr Token ist: ${token}.'

Diff for: locales/en.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,16 @@ order_detail: |
204204
seller: seller
205205
buyer: buyer
206206
dispute_started_channel: |
207-
User ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
208-
has started a dispute with @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} for the order
207+
User ${type} @${initiatorUser} TG ID: ${initiatorTgId}
208+
has started a dispute with @${counterPartyUser} TG ID: ${counterPartyUserTgId} for the order
209209
210210
${detailedOrder}
211211
212212
Seller Token: ${sellerToken}
213213
Buyer Token: ${buyerToken}
214214
215-
@${initiatorUser.username} has been involved in ${initiatorUser.disputes} disputes
216-
@${counterPartyUser.username} has been involved in ${counterPartyUser.disputes} disputes
215+
@${initiatorUser} has been involved in ${buyerDisputes} disputes
216+
@${counterPartyUser} has been involved in ${sellerDisputes} disputes
217217
you_started: '🥴 You have started a dispute on your order Id: ${orderId}.'
218218
counterpart_started: '🥴 Your counterparty started a dispute on your order Id: ${orderId}.'
219219
dispute_started: '${who} A solver will attend you soon, when he/she is assigned to your dispute the bot will tell you his/her username, only he/she will be able to attend you. You can write to him/her directly, but if he/she contacts you first, you must ask him/her to tell you what is the token of your dispute, your token is: ${token}.'

Diff for: locales/es.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,16 @@ order_detail: |
202202
seller: vendedor
203203
buyer: comprador
204204
dispute_started_channel: |
205-
El ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
206-
ha iniciado una disputa con @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} en la orden:
205+
El ${type} @${initiatorUser} TG ID: ${initiatorTgId}
206+
ha iniciado una disputa con @${counterPartyUser} TG ID: ${counterPartyUserTgId} en la orden:
207207
208208
${detailedOrder}
209209
210210
Seller Token: ${sellerToken}
211211
Buyer Token: ${buyerToken}
212212
213-
@${initiatorUser.username} ya tiene ${buyerDisputes} disputas
214-
@${counterPartyUser.username} ya tiene ${sellerDisputes} disputas
213+
@${initiatorUser} ya tiene ${buyerDisputes} disputas
214+
@${counterPartyUser} ya tiene ${sellerDisputes} disputas
215215
you_started: '🥴 Has iniciado una disputa en tu orden con Id: ${orderId}.'
216216
counterpart_started: '🥴 Tu contraparte ha iniciado una disputa en tu orden con Id: ${orderId}.'
217217
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 for: locales/fa.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,16 @@ order_detail: |
204204
seller: seller
205205
buyer: buyer
206206
dispute_started_channel: |
207-
کاربر ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
208-
بابت سفارش زیر یک مشاجره را با کاربر @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} آغاز کرده
207+
کاربر ${type} @${initiatorUser} TG ID: ${initiatorTgId}
208+
بابت سفارش زیر یک مشاجره را با کاربر @${counterPartyUser} TG ID: ${counterPartyUserTgId} آغاز کرده
209209
210210
${detailedOrder}
211211
212212
Seller Token: ${sellerToken}
213213
Buyer Token: ${buyerToken}
214214
215-
کابر@${initiatorUser.username} بابت ${initiatorUser.disputes} به اختلاف خورده
216-
کاربر@${counterPartyUser.username} بابت ${counterPartyUser.disputes} به اختلاف خورده
215+
کابر@${initiatorUser} بابت ${buyerDisputes} به اختلاف خورده
216+
کاربر@${counterPartyUser} بابت ${sellerDisputes} به اختلاف خورده
217217
you_started: '🥴 شما در مورد شناسه سفارش خود اختلاف نظر شروع کرده اید: ${orderId}.'
218218
counterpart_started: '🥴 طرف مقابل شما یک اختلاف بر سر شناسه سفارش شما شروع کرد: ${orderId}.'
219219
dispute_started: '${who} یک حل کننده به زودی در شما حضور خواهد یافت، هنگامی که او به منازعه شما منصوب شد، ربات نام کاربری خود را به شما می گوید، فقط او می تواند در شما حضور داشته باشد. شما می توانید مستقیماً برای او نامه بنویسید، اما اگر ابتدا با شما تماس گرفت، باید از او بخواهید که به شما بگوید نشانه اختلاف شما چیست، رمز شما این است: ${token}.'

Diff for: locales/fr.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,16 @@ order_detail: |
204204
seller: vendeur
205205
buyer: acheteur
206206
dispute_started_channel: |
207-
L'utilisateur ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
208-
à déclenché un litige avec @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} concernant l'offre
207+
L'utilisateur ${type} @${initiatorUser} TG ID: ${initiatorTgId}
208+
à déclenché un litige avec @${counterPartyUser} TG ID: ${counterPartyUserTgId} concernant l'offre
209209
210210
${detailedOrder}
211211
212212
Seller Token: ${sellerToken}
213213
Buyer Token: ${buyerToken}
214214
215-
@${initiatorUser.username} a été impliqué.e dans ${initiatorUser.disputes} litiges
216-
@${counterPartyUser.username} a été impliqué.e dans ${counterPartyUser.disputes} litiges
215+
@${initiatorUser} a été impliqué.e dans ${buyerDisputes} litiges
216+
@${counterPartyUser} a été impliqué.e dans ${sellerDisputes} litiges
217217
you_started : '🥴 Vous avez commencé un litige sur votre commande Id : ${orderId}.'
218218
counterpart_started : '🥴 Votre contrepartie a démarré un litige sur votre commande Id : ${orderId}.'
219219
dispute_started : "${who} Un solver va bientôt venir vous voir, lorsqu'il/elle sera assigné(e) à votre litige, le bot vous indiquera son nom d'utilisateur, il/elle seul(e) sera en mesure de venir vous voir. Vous pouvez lui écrire directement, mais s'il vous contacte en premier, vous devez lui demander de vous dire quel est le jeton de votre litige, votre jeton est : ${token}."

Diff for: locales/it.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,16 @@ order_detail: |
202202
seller: venditore
203203
buyer: acquirente
204204
dispute_started_channel: |
205-
User ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
206-
ha iniziato una disputa con @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} per l'ordine
205+
User ${type} @${initiatorUser} TG ID: ${initiatorTgId}
206+
ha iniziato una disputa con @${counterPartyUser} TG ID: ${counterPartyUserTgId} per l'ordine
207207
208208
${detailedOrder}
209209
210210
Seller Token: ${sellerToken}
211211
Buyer Token: ${buyerToken}
212212
213-
@${initiatorUser.username} è stato coinvolto in ${initiatorUser.disputes} dispute
214-
@${counterPartyUser.username} è stato coinvolto in in ${counterPartyUser.disputes} disputee
213+
@${initiatorUser} è stato coinvolto in ${buyerDisputes} dispute
214+
@${counterPartyUser} è stato coinvolto in in ${sellerDisputes} disputee
215215
you_started: '🥴 Hai aperto una controversia per il tuo ordine Id: ${orderId}.'
216216
counterpart_started: '🥴 La tua controparte ha aperto una controversia sul tuo ordine Id: ${orderId}.'
217217
dispute_started: '${who} Un risolutore ti assisterà presto, quando sarà assegnato alla tua controversia il bot ti dirà il suo nome utente, solo lui potrà assisterti. Potete scrivergli direttamente, ma se vi contatta prima, dovete chiedergli di dirvi qual è il token della vostra controversia, il vostro token è: ${token}.'

Diff for: locales/ko.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,16 @@ order_detail: |
203203
seller: 판매자
204204
buyer: 구매자
205205
dispute_started_channel: |
206-
사용자 ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
207-
님께서 @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} 와의 분쟁 조정을 시작하였습니다. 주문 상세 내역은 다음과 같습니다.
206+
사용자 ${type} @${initiatorUser} TG ID: ${initiatorTgId}
207+
님께서 @${counterPartyUser} TG ID: ${counterPartyUserTgId} 와의 분쟁 조정을 시작하였습니다. 주문 상세 내역은 다음과 같습니다.
208208
209209
${detailedOrder}
210210
211211
Seller Token: ${sellerToken}
212212
Buyer Token: ${buyerToken}
213213
214-
${initiatorUser.disputes} 분쟁 조정에 @${initiatorUser.username}님께서 참여하셨습니다.
215-
${counterPartyUser.disputes} 분쟁 조정에 @${counterPartyUser.username}님께서 참여하셨습니다.
214+
${buyerDisputes} 분쟁 조정에 @${initiatorUser}님께서 참여하셨습니다.
215+
${sellerDisputes} 분쟁 조정에 @${counterPartyUser}님께서 참여하셨습니다.
216216
you_started: '🥴 주문 ID에 대한 분쟁이 시작되었습니다: ${orderId}'
217217
counterpart_started: '🥴 거래 상대방이 주문 ID에 대해 분쟁을 시작했습니다: ${orderId}'
218218
dispute_started: '${who} 해결사가 분쟁에 배정되면 봇이 자신의 사용자 아이디를 알려주며, 해당 해결사만 분쟁에 참석할 수 있습니다. 해결사에게 직접 편지를 보낼 수도 있지만, 해결사가 먼저 연락하는 경우 분쟁의 토큰이 무엇인지 알려달라고 요청해야 합니다(토큰은 ${토큰}입니다).'

Diff for: locales/pt.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ order_detail: |
201201
seller: vendedora
202202
buyer: compradora
203203
dispute_started_channel: |
204-
Usuário ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
205-
iniciou uma disputa com @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} para o pedido
204+
Usuário ${type} @${initiatorUser} TG ID: ${initiatorTgId}
205+
iniciou uma disputa com @${counterPartyUser} TG ID: ${counterPartyUserTgId} para o pedido
206206
207207
${detailedOrder}
208208
209209
Seller Token: ${sellerToken}
210210
Buyer Token: ${buyerToken}
211211
212-
@${initiatorUser.username} esteve envolvido em ${initiatorUser.disputes} disputas
213-
@${counterPartyUser.username} esteve envolvido em ${counterPartyUser.disputes} disputas
212+
@${initiatorUser} esteve envolvido em ${buyerDisputes} disputas
213+
@${counterPartyUser} esteve envolvido em ${sellerDisputes} disputas
214214
you_started: '🥴 Você iniciou uma disputa em seu pedido Id: ${orderId}.'
215215
counterpart_started: '🥴 Sua contraparte iniciou uma disputa em seu pedido Id: ${orderId}.'
216216
dispute_started: '${who} Um solucionador o atenderá em breve. Quando ele for designado para sua disputa, o bot informará seu nome de usuário e somente ele poderá atendê-lo. Você pode escrever diretamente para ele/ela, mas se ele/ela entrar em contato com você primeiro, você deve pedir a ele/ela que lhe diga qual é o token de sua disputa, seu token é: ${token}.'

Diff for: locales/ru.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ order_detail: |
201201
seller: продавец
202202
buyer: покупатель
203203
dispute_started_channel: |
204-
${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
205-
инициировал разбирательство с @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} относительно заявки:
204+
${type} @${initiatorUser} TG ID: ${initiatorTgId}
205+
инициировал разбирательство с @${counterPartyUser} TG ID: ${counterPartyUserTgId} относительно заявки:
206206
207207
${detailedOrder}
208208
209209
Seller Token: ${sellerToken}
210210
Buyer Token: ${buyerToken}
211211
212-
@${initiatorUser.username} уже имел разбирательств: ${initiatorUser.disputes}
213-
@${counterPartyUser.username} уже имел разбирательств: ${counterPartyUser.disputes}
212+
@${initiatorUser} уже имел разбирательств: ${buyerDisputes}
213+
@${counterPartyUser} уже имел разбирательств: ${sellerDisputes}
214214
you_started: '🥴 Вы начали спор по вашему заказу Id: ${orderId}.'
215215
counterpart_started: '🥴 Ваш контрагент начал спор по вашему заказу Id: ${orderId}.'
216216
dispute_started: '${who} Скоро к вам придет решатель, когда он будет назначен на ваш спор, бот сообщит вам его/ее имя пользователя, только он/она сможет прийти к вам. Вы можете написать ему напрямую, но если он свяжется с вами первым, вы должны попросить его сказать вам, какой токен у вашего спора, ваш токен: ${token}.'

Diff for: locales/uk.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ order_detail: |
201201
seller: продавець
202202
buyer: покупець
203203
dispute_started_channel: |
204-
${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
205-
ініціював диспут з @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} щодо заявки:
204+
${type} @${initiatorUser} TG ID: ${initiatorTgId}
205+
ініціював диспут з @${counterPartyUser} TG ID: ${counterPartyUserTgId} щодо заявки:
206206
207207
${detailedOrder}
208208
209209
Seller Token: ${sellerToken}
210210
Buyer Token: ${buyerToken}
211211
212-
@${initiatorUser.username} вже мав спір: ${initiatorUser.disputes}
213-
@${counterPartyUser.username} вже мав спір: ${counterPartyUser.disputes}
212+
@${initiatorUser} вже мав спір: ${buyerDdisputes}
213+
@${counterPartyUser} вже мав спір: ${sellerDisputes}
214214
you_started: '🥴 Ви почали оскарження свого замовлення з ідентифікатором: ${orderId}.'
215215
counterpart_started: '🥴 Ваш контрагент розпочав суперечку щодо вашого замовлення з ідентифікатором: ${orderId}.'
216216
dispute_started: "${who} Розв'язувач незабаром прийде до вас, коли його/її буде призначено до вашої суперечки, бот повідомить вам своє ім'я користувача, лише він/вона зможе прийти до вас. Ви можете написати йому/їй безпосередньо, але якщо він/вона зв’яжеться з вами першим, ви повинні попросити його/її сказати вам, що є символом вашої суперечки, ваш маркер: ${token}."

Diff for: tests/bot/modules/dispute/messages.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ const mockI18n = {
1616
t: sinon.stub((key, params) => {
1717
switch (key) {
1818
case 'dispute_started_channel':
19-
return `User ${params.type} @${params.initiatorUser.username} TG ID: ${params.initiatorTgId}
20-
has started a dispute with @${params.counterPartyUser.username} TG ID: ${params.counterPartyUserTgId} for the order
19+
return `User ${params.type} @${params.initiatorUser} TG ID: ${params.initiatorTgId}
20+
has started a dispute with @${params.counterPartyUser} TG ID: ${params.counterPartyUserTgId} for the order
2121
2222
${params.detailedOrder}
2323
2424
Seller Token: ${params.sellerToken}
2525
Buyer Token: ${params.buyerToken}
2626
27-
@${params.initiatorUser.username} has been involved in ${params.buyerDisputes} disputes
28-
@${params.counterPartyUser.username} has been involved in ${params.sellerDisputes} disputes`;
27+
@${params.initiatorUser} has been involved in ${params.buyerDisputes} disputes
28+
@${params.counterPartyUser} has been involved in ${params.sellerDisputes} disputes`;
2929
case 'seller':
3030
return 'seller';
3131
case 'buyer':

Diff for: util/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ const getDetailedOrder = (i18n: I18nContext, order: IOrder, buyer: UserDocument,
368368
takenAt = sanitizeMD(takenAt);
369369
const previousDisputeStatus = sanitizeMD(order.previous_dispute_status);
370370
const status = sanitizeMD(order.status);
371-
const fee = order.fee ? Number(order.fee) : '';
371+
const fee = order.fee ? sanitizeMD(Number(order.fee)) : '';
372372
const creator =
373373
order.creator_id === buyerId ? buyerUsername : sellerUsername;
374374
const buyerAge = buyer? getUserAge(buyer) : '';

0 commit comments

Comments
 (0)