Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid a buyer taking the same order twice in status waiting-buyer-invoice #350

Merged
merged 1 commit into from
Sep 17, 2024
Merged
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
19 changes: 2 additions & 17 deletions src/app/take_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ pub async fn take_sell_action(
}
};

// Buyer can take Pending or WaitingBuyerInvoice orders only
// Buyer can take Pending orders only
match order_status {
Status::Pending | Status::WaitingBuyerInvoice => {}
Status::Pending => {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If @Catrya did a round of test and it work, for me it's a direct merge.

_ => {
send_new_order_msg(
Some(order.id),
Expand All @@ -126,21 +126,6 @@ pub async fn take_sell_action(
order.taken_at = Timestamp::now().as_u64() as i64;
}

if order_status == Status::WaitingBuyerInvoice {
if let Some(ref buyer) = order.buyer_pubkey {
if buyer != &buyer_pubkey.to_string() {
send_new_order_msg(
Some(order.id),
Action::NotAllowedByStatus,
None,
&buyer_pubkey,
)
.await;
return Ok(());
}
}
}

// Check market price value in sats - if order was with market price then calculate it and send a DM to buyer
if order.amount == 0 {
let (new_sats_amount, fee) =
Expand Down
Loading