Skip to content

Commit

Permalink
moved insid app.rs functions all getter of request_id
Browse files Browse the repository at this point in the history
  • Loading branch information
arkanoider committed Nov 7, 2024
1 parent 959d1e1 commit 6bc3588
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 42 deletions.
48 changes: 18 additions & 30 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
{
Expand All @@ -134,18 +128,17 @@ 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
{
warning_msg(&action, e)
}
}
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)
}
Expand All @@ -158,25 +151,22 @@ pub async fn run(
&my_keys,
&pool,
rate_list.clone(),
request_id,
)
.await
{
warning_msg(&action, e)
}
}
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
{
Expand All @@ -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
{
Expand All @@ -194,18 +184,16 @@ 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
{
warning_msg(&action, e)
}
}
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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/add_invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ pub async fn add_invoice_action(
event: &UnwrappedGift,
my_keys: &Keys,
pool: &Pool<Sqlite>,
request_id: Option<u64>,
) -> 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,
Expand Down
4 changes: 3 additions & 1 deletion src/app/admin_add_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ pub async fn admin_add_solver_action(
event: &UnwrappedGift,
my_keys: &Keys,
pool: &Pool<Sqlite>,
request_id: Option<u64>,
) -> 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
Expand Down
4 changes: 3 additions & 1 deletion src/app/admin_cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ pub async fn admin_cancel_action(
my_keys: &Keys,
pool: &Pool<Sqlite>,
ln_client: &mut LndConnector,
request_id: Option<u64>,
) -> 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 {
Expand Down
4 changes: 3 additions & 1 deletion src/app/admin_settle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ pub async fn admin_settle_action(
my_keys: &Keys,
pool: &Pool<Sqlite>,
ln_client: &mut LndConnector,
request_id: Option<u64>,
) -> 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 {
Expand Down
4 changes: 3 additions & 1 deletion src/app/admin_take_dispute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ pub async fn admin_take_dispute_action(
msg: Message,
event: &UnwrappedGift,
pool: &Pool<Sqlite>,
request_id: Option<u64>,
) -> 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
Expand Down
4 changes: 3 additions & 1 deletion src/app/cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ pub async fn cancel_action(
my_keys: &Keys,
pool: &Pool<Sqlite>,
ln_client: &mut LndConnector,
request_id: Option<u64>,
) -> 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 {
Expand Down
4 changes: 3 additions & 1 deletion src/app/dispute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ pub async fn dispute_action(
event: &UnwrappedGift,
my_keys: &Keys,
pool: &Pool<Sqlite>,
request_id: Option<u64>,
) -> 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 {
Expand Down
4 changes: 3 additions & 1 deletion src/app/fiat_sent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ pub async fn fiat_sent_action(
event: &UnwrappedGift,
my_keys: &Keys,
pool: &Pool<Sqlite>,
request_id: Option<u64>,
) -> 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 {
Expand Down
4 changes: 3 additions & 1 deletion src/app/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ pub async fn order_action(
event: &UnwrappedGift,
my_keys: &Keys,
pool: &Pool<Sqlite>,
request_id: Option<u64>,
) -> 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();

Expand Down
4 changes: 3 additions & 1 deletion src/app/rate_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ pub async fn update_user_reputation_action(
my_keys: &Keys,
pool: &Pool<Sqlite>,
rate_list: Arc<Mutex<Vec<Event>>>,
request_id: Option<u64>,
) -> 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 {
Expand Down
4 changes: 3 additions & 1 deletion src/app/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ pub async fn release_action(
my_keys: &Keys,
pool: &Pool<Sqlite>,
ln_client: &mut LndConnector,
request_id: Option<u64>,
) -> 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
Expand Down
4 changes: 3 additions & 1 deletion src/app/take_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ pub async fn take_sell_action(
event: &UnwrappedGift,
my_keys: &Keys,
pool: &Pool<Sqlite>,
request_id: Option<u64>,
) -> 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
Expand Down

0 comments on commit 6bc3588

Please sign in to comment.