diff --git a/src/app.rs b/src/app.rs index c9ba0e8..ad4730d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -82,9 +82,6 @@ pub async fn run( match message { Ok(msg) => { if msg.get_inner_message_kind().verify() { - // Get the optional request id - let request_id = msg.get_inner_message_kind().request_id; - if let Some(action) = msg.inner_action() { match action { Action::NewOrder => { @@ -102,10 +99,8 @@ pub async fn run( } } Action::TakeBuy => { - if let Err(e) = take_buy_action( - msg, &event, &my_keys, &pool, request_id, - ) - .await + if let Err(e) = + take_buy_action(msg, &event, &my_keys, &pool).await { warning_msg(&action, e) } diff --git a/src/app/add_invoice.rs b/src/app/add_invoice.rs index 4940124..413e9c4 100644 --- a/src/app/add_invoice.rs +++ b/src/app/add_invoice.rs @@ -155,7 +155,7 @@ pub async fn add_invoice_action( // We send a confirmation message to seller send_new_order_msg( - request_id, + None, Some(order.id), Action::BuyerTookOrder, Some(Content::Order(order_data.clone())), diff --git a/src/app/release.rs b/src/app/release.rs index e2bf435..52cab52 100644 --- a/src/app/release.rs +++ b/src/app/release.rs @@ -145,14 +145,7 @@ pub async fn release_action( Some(buyer) => PublicKey::from_str(buyer.as_str())?, _ => return Err(Error::msg("Missing buyer pubkeys")), }; - send_new_order_msg( - request_id, - Some(order_id), - Action::Released, - None, - &buyer_pubkey, - ) - .await; + send_new_order_msg(None, Some(order_id), Action::Released, None, &buyer_pubkey).await; let _ = do_payment(order_updated, request_id).await; @@ -254,7 +247,7 @@ async fn payment_success( ) -> Result<()> { // Purchase completed message to buyer send_new_order_msg( - request_id, + None, Some(order.id), Action::PurchaseCompleted, None, @@ -353,7 +346,7 @@ async fn payment_success( Ordering::Less => {} } } else { - send_cant_do_msg(request_id, Some(order.id), None, buyer_pubkey).await; + send_cant_do_msg(None, Some(order.id), None, buyer_pubkey).await; send_cant_do_msg(request_id, Some(order.id), None, seller_pubkey).await; } } diff --git a/src/app/take_buy.rs b/src/app/take_buy.rs index f806c53..88ae886 100644 --- a/src/app/take_buy.rs +++ b/src/app/take_buy.rs @@ -18,7 +18,6 @@ pub async fn take_buy_action( event: &UnwrappedGift, my_keys: &Keys, pool: &Pool, - request_id: Option, ) -> Result<()> { // Safe unwrap as we verified the message let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { @@ -27,6 +26,8 @@ pub async fn take_buy_action( return Err(Error::msg("No order id")); }; + let request_id = msg.get_inner_message_kind().request_id; + let mut order = match Order::by_id(pool, order_id).await? { Some(order) => order, None => {