Skip to content

Commit

Permalink
Makers can't take own orders (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch committed Apr 8, 2024
1 parent 43e27e8 commit 1355fc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app/take_buy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ pub async fn take_buy_action(
return Ok(());
}
};
// Maker can't take own order
if order.creator_pubkey == event.pubkey.to_hex() {
send_cant_do_msg(Some(order.id), None, &event.pubkey).await;
return Ok(());
}
// We check if the message have a pubkey
if msg.get_inner_message_kind().pubkey.is_none() {
// We create a Message
send_cant_do_msg(Some(order.id), None, &event.pubkey).await;
return Ok(());
}
Expand Down
7 changes: 7 additions & 0 deletions src/app/take_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ pub async fn take_sell_action(
return Ok(());
}
};
// Maker can't take own order
if order.creator_pubkey == event.pubkey.to_hex() {
send_cant_do_msg(Some(order.id), None, &event.pubkey).await;
return Ok(());
}

if order.kind != Kind::Sell.to_string() {
return Ok(());
}

// We check if the message have a pubkey
if msg.get_inner_message_kind().pubkey.is_none() {
send_cant_do_msg(Some(order.id), None, &event.pubkey).await;
Expand Down

0 comments on commit 1355fc7

Please sign in to comment.