feature(receiver): added success request to receiver
This commit is contained in:
parent
3508ea5fd2
commit
cf0f140ba3
2 changed files with 19 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
use hex;
|
use hex;
|
||||||
use reqwest;
|
use reqwest::{self, Client};
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
|
|
@ -23,3 +23,16 @@ pub async fn download_info(relay: &str, name: &str) -> Result<TransferResponse>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn download_success(relay: &str, name: &str) -> Result<()> {
|
||||||
|
let url = String::from("http://") + relay;
|
||||||
|
let hashed_name = Sha256::digest(name.as_bytes());
|
||||||
|
let hashed_string = hex::encode(hashed_name);
|
||||||
|
|
||||||
|
let client = Client::new();
|
||||||
|
let _ = client
|
||||||
|
.post(format!("{}/download_success/{}", url, hashed_string))
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,11 @@ pub async fn start_receiver(relay: &str, name: &str) {
|
||||||
debug!("Failed to connect remote: {relay_err}");
|
debug!("Failed to connect remote: {relay_err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let success = http_client::download_success(relay, name).await;
|
||||||
|
match success {
|
||||||
|
Ok(()) => debug!("Success"),
|
||||||
|
Err(e) => error!("Error: {e:?}"),
|
||||||
|
};
|
||||||
|
|
||||||
// if let Err(e) = start_ws_com(res_ip.as_str(), res.local_room_id.as_str()).await {
|
// if let Err(e) = start_ws_com(res_ip.as_str(), res.local_room_id.as_str()).await {
|
||||||
// debug!("Failed to connect local with first room_id: {e}");
|
// debug!("Failed to connect local with first room_id: {e}");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue