diff --git a/xmpp/src/agent.rs b/xmpp/src/agent.rs index df31db7..3f23462 100644 --- a/xmpp/src/agent.rs +++ b/xmpp/src/agent.rs @@ -90,7 +90,7 @@ impl Agent { event_loop::wait_for_events(self).await } - pub async fn upload_file_with(&mut self, service: &str, path: &Path) { + pub async fn upload_file_with(&mut self, service: Jid, path: &Path) { upload::send::upload_file_with(self, service, path).await } diff --git a/xmpp/src/upload/send.rs b/xmpp/src/upload/send.rs index 99a146f..7bb4dc6 100644 --- a/xmpp/src/upload/send.rs +++ b/xmpp/src/upload/send.rs @@ -14,21 +14,21 @@ use tokio_xmpp::{ use crate::Agent; -pub async fn upload_file_with( - agent: &mut Agent, - service: &str, - path: &Path, -) { +/// Upload a file to the HTTP server associated with a given Jid. +/// +/// # Arguments +/// - `agent`: The XMPP agent through which to negociate the request. +/// - `service`: The Jid of the HTTP server to upload the file to. +/// - `path`: The path to the file to upload. +pub async fn upload_file_with(agent: &mut Agent, service: Jid, path: &Path) { // Create the IQ request to upload the file. - let request = Iq::from_get("upload1", slotslot_request_for_file(path).await) - .with_to(service.parse::().unwrap().clone()); + let request = + Iq::from_get("upload1", slotslot_request_for_file(path).await).with_to(service.clone()); // Record the upload request so we can handle the response later. - agent.uploads.push(( - String::from("upload1"), - service.parse::().unwrap(), - path.to_path_buf(), - )); + agent + .uploads + .push((String::from("upload1"), service, path.to_path_buf())); // Send the request to the server. agent.client.send_stanza(request.into()).await.unwrap();