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 was getting a
confusing message:

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

Now the bot sends a message that tells the buyer:

```
Order orderId has been cancelled. There is no need to create an invoice.
```

Fixes: #482
  • Loading branch information
Mersho authored and knocte committed May 13, 2024
1 parent 211763f commit f566dab
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 @@ -331,7 +331,7 @@ const cancelAddInvoice = async (ctx, order, job) => {
);
}
} else {
await messages.successCancelOrderMessage(ctx, user, order, i18nCtx);
await messages.successCancelOrderInvoiceMessage(ctx, user, order, i18nCtx);
}
OrderEvents.orderUpdated(order);
}
Expand Down
12 changes: 12 additions & 0 deletions bot/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,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 @@ -1667,6 +1678,7 @@ module.exports = {
successCompleteOrderMessage,
successCancelOrderByAdminMessage,
successCancelOrderMessage,
successCancelOrderInvoiceMessage,
badStatusOnCancelOrderMessage,
orderIsAlreadyCanceledMessage,
invoicePaymentFailedMessage,
Expand Down
1 change: 1 addition & 0 deletions locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,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!
already_cancelled: The order has already been cancelled!
order_cancelled_by_admin: 'Admin has cancelled the order ID: ${orderId}!'
Expand Down

0 comments on commit f566dab

Please sign in to comment.