Skip to content

Commit

Permalink
commands: Inform buyer when order is canceled
Browse files Browse the repository at this point in the history
When the seller cancels an order, the buyer will get a wrong
and confusing message:

```
You have cancelled the order ID: orderID
```

So, in this commit, the bot
sends a message that tells them: "Order orderId has been
cancelled. There is no need to create an invoice."
  • Loading branch information
Mersho committed Mar 13, 2024
1 parent 678be5b commit d59fc2f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bot/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ const cancelAddInvoice = async (ctx, order, job) => {
);
}
} else {
await messages.successCancelOrderMessage(ctx, user, order, i18nCtx);
await messages.successCancelOrderInvoiceMessage(ctx, user, order, i18nCtx);
}
}
} catch (error) {
Expand Down
12 changes: 12 additions & 0 deletions bot/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,17 @@ const successCancelOrderMessage = async (ctx: MainContext, user: UserDocument, o
}
};

const successCancelOrderInvoiceMessage = async (ctx: MainContext, user: UserDocument, order: IOrder, i18n: I18nContext) => {
try {
await ctx.telegram.sendMessage(
user.tg_id,
i18n.t('cancel_invoice', { orderId: order._id })
);
} catch (error) {
logger.error(error);
}
};

const counterPartyCancelOrderMessage = async (ctx: MainContext, user: UserDocument, order: IOrder, i18n: I18nContext) => {
try {
await ctx.telegram.sendMessage(
Expand Down Expand Up @@ -1680,6 +1691,7 @@ module.exports = {
successCompleteOrderMessage,
successCancelOrderByAdminMessage,
successCancelOrderMessage,
successCancelOrderInvoiceMessage,
badStatusOnCancelOrderMessage,
invoicePaymentFailedMessage,
userCantTakeMoreThanOneWaitingOrderMessage,
Expand Down
1 change: 1 addition & 0 deletions locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ invoice_already_being_paid: You have alreday send an invoice for this order and
lightning_address_saved: Lightning address has been saved
cancel_error: This order cannot be cancelled at this moment
cancel_success: 'You have cancelled the order ID: ${orderId}!'
cancel_invoice: 'Order ${orderId} has been cancelled, no need to create an invoice.'
cancelall_success: You have cancelled all your published orders!
order_cancelled_by_admin: 'Admin has cancelled the order ID: ${orderId}!'
order_completed: 'You have completed the order ID: ${orderId}!'
Expand Down

0 comments on commit d59fc2f

Please sign in to comment.