Skip to content

Commit

Permalink
feat: handles cancel request for already cancelled order & removes re…
Browse files Browse the repository at this point in the history
…dundant check
  • Loading branch information
bilthon committed Nov 13, 2024
1 parent 22d3a30 commit 416bc63
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/app/cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ pub async fn cancel_action(
}
};

if order.status == Status::Canceled.to_string()
|| order.status == Status::CooperativelyCanceled.to_string()
|| order.status == Status::CanceledByAdmin.to_string()
{
error!("Order {} is already canceled", order_id);
send_cant_do_msg(
request_id,
Some(order_id),
Some("Order already canceled".to_string()),
&event.sender,
)
.await;
return Ok(());
}

if order.status == Status::Pending.to_string() {
// Validates if this user is the order creator
if user_pubkey != order.creator_pubkey {
Expand Down Expand Up @@ -73,8 +88,7 @@ pub async fn cancel_action(
}

if order.kind == OrderKind::Sell.to_string()
&& (order.status == Status::WaitingBuyerInvoice.to_string()
|| order.status == Status::WaitingBuyerInvoice.to_string())
&& (order.status == Status::WaitingBuyerInvoice.to_string())
{
cancel_add_invoice(ln_client, &mut order, event, pool, my_keys, request_id).await?;
}
Expand Down

0 comments on commit 416bc63

Please sign in to comment.