Skip to content

Commit

Permalink
Code refactoring and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch committed Dec 7, 2023
1 parent a341344 commit e1489b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/app/admin_take_dispute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ pub async fn admin_take_dispute_action(

return Ok(());
}
// TODO: update dispute nostr event status

take_dispute(pool, &Status::InProgress, dispute_id, &event.pubkey).await?;

// We create a Message for admin
Expand Down
19 changes: 13 additions & 6 deletions src/app/fiat_sent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@ pub async fn fiat_sent_action(
let order = match Order::by_id(pool, order_id).await? {
Some(order) => order,
None => {
error!("FiatSent: Order Id {order_id} not found!");
error!("Order Id {order_id} not found!");
return Ok(());
}
};
// TODO: send to user a DM with the error
// Send to user a DM with the error
if order.status != "Active" {
error!("Order Id {order_id} wrong status");
let error = "Order Id {order_id} wrong status";
error!("{}", error);
let message = Message::cant_do(
Some(order.id),
None,
Some(Content::TextMessage(error.to_string())),
);
send_dm(client, my_keys, &event.pubkey, message.as_json()?).await?;

return Ok(());
}
// 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.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;
send_dm(client, my_keys, &event.pubkey, message.as_json()?).await?;

return Ok(());
}
Expand Down Expand Up @@ -72,5 +78,6 @@ pub async fn fiat_sent_action(
);
let message = message.as_json()?;
send_dm(client, my_keys, &event.pubkey, message).await?;

Ok(())
}
2 changes: 1 addition & 1 deletion src/app/rate_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::time::Duration;
use tokio::sync::Mutex;

pub async fn get_counterpart_reputation(
user: &String,
user: &str,
my_keys: &Keys,
client: &Client,
) -> Result<Option<Rating>> {
Expand Down

0 comments on commit e1489b7

Please sign in to comment.