Skip to content

Commit

Permalink
cargo fmt executed
Browse files Browse the repository at this point in the history
  • Loading branch information
arkanoider committed Nov 30, 2023
1 parent 3a28b6c commit d189dbc
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/app/admin_add_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn admin_add_solver_action(
// Check if the pubkey is Mostro
if event.pubkey.to_bech32()? != mostro_pubkey {
// We create a Message
let message = Message::cant_do( None, None, None);
let message = Message::cant_do(None, None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand Down
2 changes: 1 addition & 1 deletion src/app/admin_settle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub async fn admin_settle_action(
d.update(pool).await?;
}
// We create a Message
let message = Message::new( Some(order.id), None, Action::AdminSettle, None);
let message = Message::new(Some(order.id), None, Action::AdminSettle, None);
let message = message.as_json()?;
// Message to admin
send_dm(client, my_keys, &event.pubkey, message.clone()).await?;
Expand Down
4 changes: 2 additions & 2 deletions src/app/admin_take_dispute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn admin_take_dispute_action(
// TODO: solvers also can take disputes
if event.pubkey.to_bech32()? != mostro_pubkey {
// We create a Message
let message = Message::cant_do( None, None, None);
let message = Message::cant_do(None, None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand All @@ -43,7 +43,7 @@ pub async fn admin_take_dispute_action(
take_dispute(pool, &Status::InProgress, dispute_id, &event.pubkey).await?;

// We create a Message for admin
let message = Message::new( None, None, Action::AdminAddSolver, None);
let message = Message::new(None, None, Action::AdminAddSolver, None);
let message = message.as_json()?;
// Send the message
send_dm(client, my_keys, &event.pubkey, message.clone()).await?;
Expand Down
14 changes: 7 additions & 7 deletions src/app/cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ pub async fn cancel_action(
// Validates if this user is the order creator
if user_pubkey != order.creator_pubkey {
// We create a Message
let message = Message::cant_do( Some(order.id), None, None);
let message = Message::cant_do(Some(order.id), None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;
} else {
// We publish a new replaceable kind nostr event with the status updated
// and update on local database the status and new event id
update_order_event(pool, client, my_keys, Status::Canceled, &order, None).await?;
// We create a Message for cancel
let message = Message::new( Some(order.id), None, Action::Cancel, None);
let message = Message::new(Some(order.id), None, Action::Cancel, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;
}
Expand Down Expand Up @@ -74,7 +74,7 @@ pub async fn cancel_action(
Some(ref initiator_pubkey) => {
if initiator_pubkey == &user_pubkey {
// We create a Message
let message = Message::cant_do( Some(order.id), None, None);
let message = Message::cant_do(Some(order.id), None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand Down Expand Up @@ -164,7 +164,7 @@ pub async fn cancel_add_invoice(
let seller_pubkey = XOnlyPublicKey::from_bech32(seller_pubkey)?;
if buyer_pubkey_bech32 != &user_pubkey {
// We create a Message
let message = Message::cant_do( Some(order.id), None, None);
let message = Message::cant_do(Some(order.id), None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand All @@ -184,7 +184,7 @@ pub async fn cancel_add_invoice(
)
.await?;
// We create a Message for cancel
let message = Message::new( Some(order.id), None, Action::Cancel, None);
let message = Message::new(Some(order.id), None, Action::Cancel, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message.clone()).await?;
send_dm(client, my_keys, &seller_pubkey, message).await?;
Expand Down Expand Up @@ -227,7 +227,7 @@ pub async fn cancel_pay_hold_invoice(
let seller_pubkey = XOnlyPublicKey::from_bech32(seller_pubkey_bech32)?;
if seller_pubkey_bech32 != &user_pubkey {
// We create a Message
let message = Message::cant_do( Some(order.id), None, None);
let message = Message::cant_do(Some(order.id), None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand All @@ -239,7 +239,7 @@ pub async fn cancel_pay_hold_invoice(
// and update on local database the status and new event id
update_order_event(pool, client, my_keys, Status::Canceled, order, None).await?;
// We create a Message for cancel
let message = Message::new( Some(order.id), None, Action::Cancel, None);
let message = Message::new(Some(order.id), None, Action::Cancel, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message.clone()).await?;
send_dm(client, my_keys, &seller_pubkey, message).await?;
Expand Down
4 changes: 2 additions & 2 deletions src/app/dispute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub async fn dispute_action(
// Add a check in case of no counterpart found
if counterpart.is_empty() {
// We create a Message
let message = Message::cant_do( Some(order.id), None, None);
let message = Message::cant_do(Some(order.id), None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand All @@ -71,7 +71,7 @@ pub async fn dispute_action(
add_dispute(&dispute, pool).await?;

// We create a Message for the initiator
let message = Message::new( Some(order.id), None, Action::DisputeInitiatedByYou, None);
let message = Message::new(Some(order.id), None, Action::DisputeInitiatedByYou, None);
let message = message.as_json()?;
let initiator_pubkey = XOnlyPublicKey::from_bech32(message_sender)?;
send_dm(client, my_keys, &initiator_pubkey, message).await?;
Expand Down
2 changes: 1 addition & 1 deletion src/app/fiat_sent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub async fn fiat_sent_action(
// Check if the pubkey is the buyer
if Some(event.pubkey.to_bech32()?) != order.buyer_pubkey {
// We create a Message
let message = Message::cant_do( Some(order.id), None, None);
let message = Message::cant_do(Some(order.id), None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand Down
2 changes: 1 addition & 1 deletion src/app/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub async fn order_action(
Some(ref pk) => pk,
None => {
// We create a Message
let message = Message::cant_do( order.id, None, None);
let message = Message::cant_do(order.id, None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand Down
4 changes: 2 additions & 2 deletions src/app/rate_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub async fn update_user_reputation_action(
let message_sender = event.pubkey.to_bech32()?;

if order.status != "Success" {
let message = Message::cant_do( Some(order.id), None, None);
let message = Message::cant_do(Some(order.id), None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;
error!("Order Id {order_id} wrong status");
Expand All @@ -89,7 +89,7 @@ pub async fn update_user_reputation_action(
// Add a check in case of no counterpart found
if counterpart.is_empty() {
// We create a Message
let message = Message::cant_do( Some(order.id), None, None);
let message = Message::cant_do(Some(order.id), None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand Down
4 changes: 2 additions & 2 deletions src/app/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub async fn release_action(
let message = message.as_json()?;
send_dm(client, my_keys, &seller_pubkey, message).await?;
// We send a message to buyer indicating seller released funds
let message = Message::new( Some(order.id), None, Action::Release, None);
let message = Message::new(Some(order.id), None, Action::Release, None);
let message = message.as_json()?;
let buyer_pubkey = XOnlyPublicKey::from_bech32(order.buyer_pubkey.as_ref().unwrap())?;
send_dm(client, my_keys, &buyer_pubkey, message).await?;
Expand Down Expand Up @@ -85,7 +85,7 @@ pub async fn release_action(
);
// Purchase completed message to buyer
let message =
Message::new( Some(order.id), None, Action::PurchaseCompleted, None);
Message::new(Some(order.id), None, Action::PurchaseCompleted, None);
let message = message.as_json().unwrap();
send_dm(&client, &my_keys, &buyer_pubkey, message)
.await
Expand Down
5 changes: 3 additions & 2 deletions src/app/take_buy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub async fn take_buy_action(
// We check if the message have a pubkey
if msg.get_inner_message_kind().pubkey.is_none() {
// We create a Message
let message = Message::cant_do( Some(order.id), None, None);
let message = Message::cant_do(Some(order.id), None, None);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Expand Down Expand Up @@ -64,7 +64,8 @@ pub async fn take_buy_action(
return Ok(());
}
// We update the master pubkey
edit_master_seller_pubkey_order(pool, order.id, msg.get_inner_message_kind().pubkey.clone()).await?;
edit_master_seller_pubkey_order(pool, order.id, msg.get_inner_message_kind().pubkey.clone())
.await?;
let seller_pubkey = event.pubkey;
// Seller can take pending orders only
if order_status != Status::Pending {
Expand Down
3 changes: 2 additions & 1 deletion src/app/take_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ pub async fn take_sell_action(
return Ok(());
}
// We update the master pubkey
edit_master_buyer_pubkey_order(pool, order.id, msg.get_inner_message_kind().pubkey.clone()).await?;
edit_master_buyer_pubkey_order(pool, order.id, msg.get_inner_message_kind().pubkey.clone())
.await?;
let buyer_pubkey_bech32 = buyer_pubkey.to_bech32().ok();
// Add buyer pubkey to order
edit_buyer_pubkey_order(pool, order_id, buyer_pubkey_bech32).await?;
Expand Down
6 changes: 3 additions & 3 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ pub async fn show_hold_invoice(
// We send the hold invoice to the seller
send_dm(client, my_keys, seller_pubkey, message).await?;

let message = Message::new_order( Some(order.id), None, Action::WaitingSellerToPay, None);
let message = Message::new_order(Some(order.id), None, Action::WaitingSellerToPay, None);
let message = message.as_json()?;

// We send a message to buyer to know that seller was requested to pay the invoice
Expand Down Expand Up @@ -438,11 +438,11 @@ pub async fn rate_counterpart(
) -> Result<()> {
// Send dm to counterparts
// to buyer
let message_to_buyer = Message::new_rate_user( order.id, None, None);
let message_to_buyer = Message::new_rate_user(order.id, None, None);
let message_to_buyer = message_to_buyer.as_json().unwrap();
send_dm(client, my_keys, buyer_pubkey, message_to_buyer).await?;
// to seller
let message_to_seller = Message::new_rate_user( order.id, None, None);
let message_to_seller = Message::new_rate_user(order.id, None, None);
let message_to_seller = message_to_seller.as_json().unwrap();
send_dm(client, my_keys, seller_pubkey, message_to_seller).await?;

Expand Down

0 comments on commit d189dbc

Please sign in to comment.