Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions bot/ordersActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ interface BuildDescriptionArguments {
currency: IFiat;
}

interface OrderTitleArguments {
user: UserDocument;
type: string;
amount: number;
fiatCode: string;
priceFromAPI: boolean;
}

interface FiatAmountData {
fiat_amount?: number;
min_amount?: number;
Expand Down Expand Up @@ -248,14 +256,13 @@ const buildDescription = (

const ageInDays = getUserAge(user);

const firstLine = getOrderTitleMessage(
const firstLine = getOrderTitleMessage(i18n, {
user,
type,
amount,
fiatCode,
priceFromAPI,
i18n,
);
});

let description: string = `${firstLine}\n`;
description += i18n.t('for') + ` ${currencyString}\n`;
Expand All @@ -274,36 +281,38 @@ const buildDescription = (
};

const getOrderTitleMessage = (
user: UserDocument,
type: string,
amount: number,
fiatCode: string,
priceFromAPI: boolean,
i18n: I18nContext,
{ user, type, amount, fiatCode, priceFromAPI }: OrderTitleArguments,
) => {
const isSell = type === 'sell';

// For fixed orders we show the sats amount; for market/range orders
// (priceFromAPI, amount === 0) the amount is omitted.
const amountText = priceFromAPI ? '' : `${numberFormat(fiatCode, amount)} `;
// Market and range orders take their price from the API and have no fixed
// sats amount at creation time, so their title shows no amount.
if (priceFromAPI) {
if (user.show_username) {
return isSell
? i18n.t('showusername_selling_sats', { username: user.username })
: i18n.t('showusername_buying_sats', { username: user.username });
}
return isSell ? i18n.t('selling_sats') : i18n.t('buying_sats');
}

// Guard Clause: The user DOES want to show their name, we resolve and leave.
// Fixed orders show the sats amount.
const formattedAmount = numberFormat(fiatCode, amount);
if (user.show_username) {
return isSell
? i18n.t('showusername_selling_sats', {
? i18n.t('showusername_selling_sats_with_amount', {
username: user.username,
amount: amountText,
amount: formattedAmount,
})
: i18n.t('showusername_buying_sats', {
: i18n.t('showusername_buying_sats_with_amount', {
username: user.username,
amount: amountText,
amount: formattedAmount,
});
}

// The user DOES NOT want to show their name.
return isSell
? i18n.t('selling_sats', { amount: amountText })
: i18n.t('buying_sats', { amount: amountText });
? i18n.t('selling_sats_with_amount', { amount: formattedAmount })
: i18n.t('buying_sats_with_amount', { amount: formattedAmount });
};

const getOrder = async (
Expand Down
12 changes: 8 additions & 4 deletions locales/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,15 @@ pending_payment_failed_to_admin: |
Zahlungsversuche: ${attempts}
selling: Verkaufe
buying: Kaufe
selling_sats: 'Verkaufe ${amount}Sats'
buying_sats: 'Kaufe ${amount}Sats'
selling_sats: Verkaufe Sats
selling_sats_with_amount: 'Verkaufe ${amount} Sats'
buying_sats: Kaufe Sats
buying_sats_with_amount: 'Kaufe ${amount} Sats'
receive_payment: Zahlung erhalten
showusername_buying_sats: '@${username} kauft ${amount}Sats'
showusername_selling_sats: '@${username} verkauft ${amount}Sats'
showusername_buying_sats: '@${username} kauft Sats'
showusername_buying_sats_with_amount: '@${username} kauft ${amount} Sats'
showusername_selling_sats: '@${username} verkauft Sats'
showusername_selling_sats_with_amount: '@${username} verkauft ${amount} Sats'
pay: Bezahlen
is: ist
trading_volume: 'Handelsvolumen: ${Volumen} Sats'
Expand Down
12 changes: 8 additions & 4 deletions locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,14 @@ pending_payment_failed_to_admin: |
Payment attempts: ${attempts}
selling: Selling
buying: Buying
selling_sats: 'Selling ${amount}sats'
buying_sats: 'Buying ${amount}sats'
showusername_selling_sats: '@${username} is selling ${amount}sats'
showusername_buying_sats: '@${username} is buying ${amount}sats'
selling_sats: Selling sats
selling_sats_with_amount: 'Selling ${amount} sats'
buying_sats: Buying sats
buying_sats_with_amount: 'Buying ${amount} sats'
showusername_selling_sats: '@${username} is selling sats'
showusername_selling_sats_with_amount: '@${username} is selling ${amount} sats'
showusername_buying_sats: '@${username} is buying sats'
showusername_buying_sats_with_amount: '@${username} is buying ${amount} sats'
receive_payment: Receive payment
pay: Pay
is: is
Expand Down
12 changes: 8 additions & 4 deletions locales/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,14 @@ pending_payment_failed_to_admin: |
Intento de pago: ${attempts}
selling: Vendiendo
buying: Comprando
selling_sats: 'Vendiendo ${amount}sats'
buying_sats: 'Comprando ${amount}sats'
showusername_buying_sats: '@${username} está comprando ${amount}sats'
showusername_selling_sats: '@${username} está vendiendo ${amount}sats'
selling_sats: Vendiendo sats
selling_sats_with_amount: 'Vendiendo ${amount} sats'
buying_sats: Comprando sats
buying_sats_with_amount: 'Comprando ${amount} sats'
showusername_buying_sats: '@${username} está comprando sats'
showusername_buying_sats_with_amount: '@${username} está comprando ${amount} sats'
showusername_selling_sats: '@${username} está vendiendo sats'
showusername_selling_sats_with_amount: '@${username} está vendiendo ${amount} sats'
receive_payment: Recibo pago
pay: Pago
is: está
Expand Down
12 changes: 8 additions & 4 deletions locales/fa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,18 @@ pending_payment_failed_to_admin: |
تعداد تلاش‌های پرداخت: ${attempts}
selling: فروختن
buying: خریدن
selling_sats: 'فروش ${amount}ساتوشی'
buying_sats: 'خرید ${amount}ساتوشی'
selling_sats: فروش ساتوشی
selling_sats_with_amount: 'فروش ${amount} ساتوشی'
buying_sats: خرید ساتوشی
buying_sats_with_amount: 'خرید ${amount} ساتوشی'
receive_payment: دریافت وجه
pay: پرداخت
is: هست
trading_volume: 'حجم معاملات: ${volume} sat'
showusername_buying_sats: '@${username} در حال خرید ${amount}ساتوشی است'
showusername_selling_sats: '@${username} در حال فروش ${amount}ساتوشی است'
showusername_buying_sats: '@${username} در حال خرید ساتوشی است'
showusername_buying_sats_with_amount: '@${username} در حال خرید ${amount} ساتوشی است'
showusername_selling_sats: '@${username} در حال فروش ساتوشی است'
showusername_selling_sats_with_amount: '@${username} در حال فروش ${amount} ساتوشی است'
satoshis: ساتوشی‌ها
by: توسط
rate: نرخ
Expand Down
12 changes: 8 additions & 4 deletions locales/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,15 @@ pending_payment_failed_to_admin: |
Tentatives de paiement : ${attempts}
selling: Vente
buying: Achat
selling_sats: 'Vente de ${amount}sats'
buying_sats: 'Achat de ${amount}sats'
selling_sats: Vente de sats
selling_sats_with_amount: 'Vente de ${amount} sats'
buying_sats: Achat de sats
buying_sats_with_amount: 'Achat de ${amount} sats'
receive_payment: Réception du paiement
showusername_buying_sats: "@${username} achète ${amount}sats"
showusername_selling_sats: "@${username} vend ${amount}sats"
showusername_buying_sats: "@${username} achète des sats"
showusername_buying_sats_with_amount: "@${username} achète ${amount} sats"
showusername_selling_sats: "@${username} vend des sats"
showusername_selling_sats_with_amount: "@${username} vend ${amount} sats"
pay: Payer
is: est
trading_volume: 'Volume de transactions : ${volume} sats'
Expand Down
12 changes: 8 additions & 4 deletions locales/it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,18 @@ pending_payment_failed_to_admin: |
Payment attempts: ${attempts}
selling: Vendita
buying: Acquisto
selling_sats: 'Vendita ${amount}sats'
buying_sats: 'Acquisto ${amount}sats'
selling_sats: Vendita sats
selling_sats_with_amount: 'Vendita ${amount} sats'
buying_sats: Acquisto sats
buying_sats_with_amount: 'Acquisto ${amount} sats'
receive_payment: Ricezione del pagamento
pay: Paga
is: è
trading_volume: 'Volume scambio: ${volume} sats'
showusername_buying_sats: '@${username} sta comprando ${amount}sats'
showusername_selling_sats: '@${username} sta vendendo ${amount}sats'
showusername_buying_sats: '@${username} sta comprando sats'
showusername_buying_sats_with_amount: '@${username} sta comprando ${amount} sats'
showusername_selling_sats: '@${username} sta vendendo sats'
showusername_selling_sats_with_amount: '@${username} sta vendendo ${amount} sats'
satoshis: satoshi
by: da
rate: Valutazione
Expand Down
12 changes: 8 additions & 4 deletions locales/ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,18 @@ pending_payment_failed_to_admin: |

selling: 팝니다
buying: 삽니다
selling_sats: '${amount}sats 판매'
buying_sats: '${amount}sats 구매'
selling_sats: sats 판매
selling_sats_with_amount: '${amount} sats 판매'
buying_sats: sats 구매
buying_sats_with_amount: '${amount} sats 구매'
receive_payment: 입금
pay: 결제
is: is
trading_volume: '거래량: ${volume} sats'
showusername_buying_sats: '@${username} 님이 ${amount}sats를 구매합니다'
showusername_selling_sats: '@${username} 님이 ${amount}sats를 판매합니다'
showusername_buying_sats: '@${username} 님이 sats를 구매합니다'
showusername_buying_sats_with_amount: '@${username} 님이 ${amount} sats를 구매합니다'
showusername_selling_sats: '@${username} 님이 sats를 판매합니다'
showusername_selling_sats_with_amount: '@${username} 님이 ${amount} sats를 판매합니다'
satoshis: 사토시
by: 방법 -
rate: 환율
Expand Down
12 changes: 8 additions & 4 deletions locales/pt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,16 @@ pending_payment_failed_to_admin: |
Tentativas de pagamento: ${attempts}
selling: Vendendo
buying: Comprando
selling_sats: 'Vendendo ${amount}sats'
buying_sats: 'Comprando ${amount}sats'
selling_sats: Vendendo sats
selling_sats_with_amount: 'Vendendo ${amount} sats'
buying_sats: Comprando sats
buying_sats_with_amount: 'Comprando ${amount} sats'
receive_payment: Receber pagamento
pay: Pagar
showusername_buying_sats: '@${username} está comprando ${amount}sats'
showusername_selling_sats: '@${username} está vendendo ${amount}sats'
showusername_buying_sats: '@${username} está comprando sats'
showusername_buying_sats_with_amount: '@${username} está comprando ${amount} sats'
showusername_selling_sats: '@${username} está vendendo sats'
showusername_selling_sats_with_amount: '@${username} está vendendo ${amount} sats'
is: é
trading_volume: 'Volume de negócios: ${volume} sats'
satoshis: satoshis
Expand Down
12 changes: 8 additions & 4 deletions locales/ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,15 @@ pending_payment_failed_to_admin: |
Попытка оплаты: ${attempts}
selling: Продаю
buying: Покупаю
selling_sats: 'Продажа ${amount}сат'
buying_sats: 'Покупка ${amount}сат'
selling_sats: Продажа сат
selling_sats_with_amount: 'Продажа ${amount} сат'
buying_sats: Покупка сат
buying_sats_with_amount: 'Покупка ${amount} сат'
receive_payment: Расчет
showusername_buying_sats: '@${username} покупает ${amount}сат'
showusername_selling_sats: '@${username} продает ${amount}сат'
showusername_buying_sats: '@${username} покупает сат'
showusername_buying_sats_with_amount: '@${username} покупает ${amount} сат'
showusername_selling_sats: '@${username} продает сат'
showusername_selling_sats_with_amount: '@${username} продает ${amount} сат'
pay: Расчет
is: Я
trading_volume: 'Обьем торгов: ${volume} сат'
Expand Down
12 changes: 8 additions & 4 deletions locales/uk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,18 @@ pending_payment_failed_to_admin: |
Спроб оплати: ${attempts}
selling: Продаю
buying: Купую
selling_sats: 'Продаж ${amount}сатоші'
buying_sats: 'Купівля ${amount}сатоші'
selling_sats: Продаж сатоші
selling_sats_with_amount: 'Продаж ${amount} сатоші'
buying_sats: Купівля сатоші
buying_sats_with_amount: 'Купівля ${amount} сатоші'
receive_payment: Розрахунок
pay: Оплата
is: є
trading_volume: 'Обсяг торгів: ${volume} сат'
showusername_buying_sats: '@${username} купує ${amount}сатоші'
showusername_selling_sats: '@${username} продає ${amount}сатоші'
showusername_buying_sats: '@${username} купує сатоші'
showusername_buying_sats_with_amount: '@${username} купує ${amount} сатоші'
showusername_selling_sats: '@${username} продає сатоші'
showusername_selling_sats_with_amount: '@${username} продає ${amount} сатоші'
satoshis: сатоші
by: за допомогою
rate: Kурс
Expand Down
Loading
Loading