Skip to content

Commit

Permalink
commands: the order is already cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
Mersho committed Mar 13, 2024
1 parent 678be5b commit 76c6d52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bot/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ const cancelOrder = async (ctx, orderId, user) => {
return await cancelShowHoldInvoice(ctx, order);
}

if (order.status === 'CANCELED')
return await messages.orderIsAlreadyCanceledMessage(ctx);

if (
!(
order.status === 'ACTIVE' ||
Expand Down
9 changes: 9 additions & 0 deletions bot/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,14 @@ const badStatusOnCancelOrderMessage = async (ctx: MainContext) => {
}
};

const orderIsAlreadyCanceledMessage = async (ctx: MainContext) => {
try {
await ctx.reply(ctx.i18n.t('already_cancelled'));
} catch (error) {
logger.error(error);
}
};

const successCancelOrderMessage = async (ctx: MainContext, user: UserDocument, order: IOrder, i18n: I18nContext) => {
try {
await ctx.telegram.sendMessage(
Expand Down Expand Up @@ -1681,6 +1689,7 @@ module.exports = {
successCancelOrderByAdminMessage,
successCancelOrderMessage,
badStatusOnCancelOrderMessage,
orderIsAlreadyCanceledMessage,
invoicePaymentFailedMessage,
userCantTakeMoreThanOneWaitingOrderMessage,
buyerReceivedSatsMessage,
Expand Down
1 change: 1 addition & 0 deletions locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ 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}!'
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}!'
order_completed: 'You have completed the order ID: ${orderId}!'
order_completed_by_admin: 'Admin has completed the order ID: ${orderId}!'
Expand Down

0 comments on commit 76c6d52

Please sign in to comment.