diff --git a/src/app.rs b/src/app.rs index 109e44e9..c9ba0e80 100644 --- a/src/app.rs +++ b/src/app.rs @@ -88,19 +88,15 @@ pub async fn run( if let Some(action) = msg.inner_action() { match action { Action::NewOrder => { - if let Err(e) = order_action( - msg, &event, &my_keys, &pool, request_id, - ) - .await + if let Err(e) = + order_action(msg, &event, &my_keys, &pool).await { warning_msg(&action, e) } } Action::TakeSell => { - if let Err(e) = take_sell_action( - msg, &event, &my_keys, &pool, request_id, - ) - .await + if let Err(e) = + take_sell_action(msg, &event, &my_keys, &pool).await { warning_msg(&action, e) } @@ -115,17 +111,15 @@ pub async fn run( } } Action::FiatSent => { - if let Err(e) = fiat_sent_action( - msg, &event, &my_keys, &pool, request_id, - ) - .await + if let Err(e) = + fiat_sent_action(msg, &event, &my_keys, &pool).await { warning_msg(&action, e) } } Action::Release => { if let Err(e) = release_action( - msg, &event, &my_keys, &pool, ln_client, request_id, + msg, &event, &my_keys, &pool, ln_client, ) .await { @@ -134,7 +128,7 @@ pub async fn run( } Action::Cancel => { if let Err(e) = cancel_action( - msg, &event, &my_keys, &pool, ln_client, request_id, + msg, &event, &my_keys, &pool, ln_client, ) .await { @@ -142,10 +136,9 @@ pub async fn run( } } Action::AddInvoice => { - if let Err(e) = add_invoice_action( - msg, &event, &my_keys, &pool, request_id, - ) - .await + if let Err(e) = + add_invoice_action(msg, &event, &my_keys, &pool) + .await { warning_msg(&action, e) } @@ -158,7 +151,6 @@ pub async fn run( &my_keys, &pool, rate_list.clone(), - request_id, ) .await { @@ -166,17 +158,15 @@ pub async fn run( } } Action::Dispute => { - if let Err(e) = dispute_action( - msg, &event, &my_keys, &pool, request_id, - ) - .await + if let Err(e) = + dispute_action(msg, &event, &my_keys, &pool).await { warning_msg(&action, e) } } Action::AdminCancel => { if let Err(e) = admin_cancel_action( - msg, &event, &my_keys, &pool, ln_client, request_id, + msg, &event, &my_keys, &pool, ln_client, ) .await { @@ -185,7 +175,7 @@ pub async fn run( } Action::AdminSettle => { if let Err(e) = admin_settle_action( - msg, &event, &my_keys, &pool, ln_client, request_id, + msg, &event, &my_keys, &pool, ln_client, ) .await { @@ -194,7 +184,7 @@ pub async fn run( } Action::AdminAddSolver => { if let Err(e) = admin_add_solver_action( - msg, &event, &my_keys, &pool, request_id, + msg, &event, &my_keys, &pool, ) .await { @@ -202,10 +192,8 @@ pub async fn run( } } Action::AdminTakeDispute => { - if let Err(e) = admin_take_dispute_action( - msg, &event, &pool, request_id, - ) - .await + if let Err(e) = + admin_take_dispute_action(msg, &event, &pool).await { warning_msg(&action, e) } diff --git a/src/app/add_invoice.rs b/src/app/add_invoice.rs index bbd13e22..4940124d 100644 --- a/src/app/add_invoice.rs +++ b/src/app/add_invoice.rs @@ -18,9 +18,9 @@ pub async fn add_invoice_action( event: &UnwrappedGift, my_keys: &Keys, pool: &Pool, - request_id: Option, ) -> Result<()> { let order_msg = msg.get_inner_message_kind(); + let request_id = msg.get_inner_message_kind().request_id; let mut order = if let Some(order_id) = order_msg.id { match Order::by_id(pool, order_id).await? { Some(order) => order, diff --git a/src/app/admin_add_solver.rs b/src/app/admin_add_solver.rs index 3e4cafdf..983e1302 100644 --- a/src/app/admin_add_solver.rs +++ b/src/app/admin_add_solver.rs @@ -14,8 +14,10 @@ pub async fn admin_add_solver_action( event: &UnwrappedGift, my_keys: &Keys, pool: &Pool, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + let inner_message = msg.get_inner_message_kind(); let content = if let Some(content) = &inner_message.content { content diff --git a/src/app/admin_cancel.rs b/src/app/admin_cancel.rs index 2722beea..1c4d75ca 100644 --- a/src/app/admin_cancel.rs +++ b/src/app/admin_cancel.rs @@ -22,8 +22,10 @@ pub async fn admin_cancel_action( my_keys: &Keys, pool: &Pool, ln_client: &mut LndConnector, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { order_id } else { diff --git a/src/app/admin_settle.rs b/src/app/admin_settle.rs index c21f0b01..c5358a89 100644 --- a/src/app/admin_settle.rs +++ b/src/app/admin_settle.rs @@ -24,8 +24,10 @@ pub async fn admin_settle_action( my_keys: &Keys, pool: &Pool, ln_client: &mut LndConnector, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { order_id } else { diff --git a/src/app/admin_take_dispute.rs b/src/app/admin_take_dispute.rs index 19947e38..7c5d26f7 100644 --- a/src/app/admin_take_dispute.rs +++ b/src/app/admin_take_dispute.rs @@ -41,8 +41,10 @@ pub async fn admin_take_dispute_action( msg: Message, event: &UnwrappedGift, pool: &Pool, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + // Find dipute id in the message let dispute_id = if let Some(dispute_id) = msg.get_inner_message_kind().id { dispute_id diff --git a/src/app/cancel.rs b/src/app/cancel.rs index 171e9430..637fd5b7 100644 --- a/src/app/cancel.rs +++ b/src/app/cancel.rs @@ -21,8 +21,10 @@ pub async fn cancel_action( my_keys: &Keys, pool: &Pool, ln_client: &mut LndConnector, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { order_id } else { diff --git a/src/app/dispute.rs b/src/app/dispute.rs index ed1506b3..150e21cb 100644 --- a/src/app/dispute.rs +++ b/src/app/dispute.rs @@ -21,8 +21,10 @@ pub async fn dispute_action( event: &UnwrappedGift, my_keys: &Keys, pool: &Pool, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { order_id } else { diff --git a/src/app/fiat_sent.rs b/src/app/fiat_sent.rs index 7b1b3041..d223e7e5 100644 --- a/src/app/fiat_sent.rs +++ b/src/app/fiat_sent.rs @@ -15,8 +15,10 @@ pub async fn fiat_sent_action( event: &UnwrappedGift, my_keys: &Keys, pool: &Pool, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { order_id } else { diff --git a/src/app/order.rs b/src/app/order.rs index c920f6c5..b256ca9c 100644 --- a/src/app/order.rs +++ b/src/app/order.rs @@ -14,8 +14,10 @@ pub async fn order_action( event: &UnwrappedGift, my_keys: &Keys, pool: &Pool, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + if let Some(order) = msg.get_inner_message_kind().get_order() { let mostro_settings = Settings::get_mostro(); diff --git a/src/app/rate_user.rs b/src/app/rate_user.rs index 99b8db48..f25ad707 100644 --- a/src/app/rate_user.rs +++ b/src/app/rate_user.rs @@ -52,8 +52,10 @@ pub async fn update_user_reputation_action( my_keys: &Keys, pool: &Pool, rate_list: Arc>>, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { order_id } else { diff --git a/src/app/release.rs b/src/app/release.rs index 5334c0e5..e2bf435f 100644 --- a/src/app/release.rs +++ b/src/app/release.rs @@ -64,8 +64,10 @@ pub async fn release_action( my_keys: &Keys, pool: &Pool, ln_client: &mut LndConnector, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + // Check if order id is ok let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { order_id diff --git a/src/app/take_sell.rs b/src/app/take_sell.rs index 9449cabb..d9afd3b3 100644 --- a/src/app/take_sell.rs +++ b/src/app/take_sell.rs @@ -19,8 +19,10 @@ pub async fn take_sell_action( event: &UnwrappedGift, my_keys: &Keys, pool: &Pool, - request_id: Option, ) -> Result<()> { + // Get request id + let request_id = msg.get_inner_message_kind().request_id; + // Safe unwrap as we verified the message let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { order_id