|
@@ -276,6 +276,75 @@ pub async fn delete_email_by_uid(list: String, uid: u32) -> anyhow::Result<()>{
|
|
Ok(())
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#[cfg(not(target_os = "wasi"))]
|
|
|
|
+pub async fn create_folder(name: String) -> anyhow::Result<()>{
|
|
|
|
+ let tls = native_tls::TlsConnector::builder().build().unwrap();
|
|
|
|
+ let client = imap::connect((Config::global().imap_domain.clone(), 993), Config::global().imap_domain.clone(), &tls).unwrap();
|
|
|
|
+ let mut imap_session = client
|
|
|
|
+ .login(Config::global().username.clone(), Config::global().password.clone())
|
|
|
|
+ .map_err(|e| e.0)?;
|
|
|
|
+
|
|
|
|
+ imap_session.create(name)?;
|
|
|
|
+ imap_session.logout()?;
|
|
|
|
+
|
|
|
|
+ Ok(())
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#[cfg(target_os = "wasi")]
|
|
|
|
+pub async fn create_folder(name: String) -> anyhow::Result<()>{
|
|
|
|
+ let mut client = connect_to_imap_server(Config::global().imap_domain.clone() ,993).await?; // TODO move port to config
|
|
|
|
+ client.login(Config::global().username.clone(), Config::global().password.clone()).await?;
|
|
|
|
+ client.create_folder(name.clone()).await?;
|
|
|
|
+ client.logout().await?;
|
|
|
|
+ Ok(())
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#[cfg(not(target_os = "wasi"))]
|
|
|
|
+pub async fn rename_folder(name: String, new_name: String) -> anyhow::Result<()>{
|
|
|
|
+ let tls = native_tls::TlsConnector::builder().build().unwrap();
|
|
|
|
+ let client = imap::connect((Config::global().imap_domain.clone(), 993), Config::global().imap_domain.clone(), &tls).unwrap();
|
|
|
|
+ let mut imap_session = client
|
|
|
|
+ .login(Config::global().username.clone(), Config::global().password.clone())
|
|
|
|
+ .map_err(|e| e.0)?;
|
|
|
|
+
|
|
|
|
+ imap_session.rename(name, new_name)?;
|
|
|
|
+ imap_session.logout()?;
|
|
|
|
+
|
|
|
|
+ Ok(())
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#[cfg(target_os = "wasi")]
|
|
|
|
+pub async fn rename_folder(name: String, new_name: String) -> anyhow::Result<()>{
|
|
|
|
+ let mut client = connect_to_imap_server(Config::global().imap_domain.clone() ,993).await?; // TODO move port to config
|
|
|
|
+ client.login(Config::global().username.clone(), Config::global().password.clone()).await?;
|
|
|
|
+ client.rename_folder(name.clone(), new_name.clone()).await?;
|
|
|
|
+ client.logout().await?;
|
|
|
|
+ Ok(())
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#[cfg(not(target_os = "wasi"))]
|
|
|
|
+pub async fn delete_folder(name: String) -> anyhow::Result<()>{
|
|
|
|
+ let tls = native_tls::TlsConnector::builder().build().unwrap();
|
|
|
|
+ let client = imap::connect((Config::global().imap_domain.clone(), 993), Config::global().imap_domain.clone(), &tls).unwrap();
|
|
|
|
+ let mut imap_session = client
|
|
|
|
+ .login(Config::global().username.clone(), Config::global().password.clone())
|
|
|
|
+ .map_err(|e| e.0)?;
|
|
|
|
+
|
|
|
|
+ imap_session.delete(name)?;
|
|
|
|
+ imap_session.logout()?;
|
|
|
|
+
|
|
|
|
+ Ok(())
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#[cfg(target_os = "wasi")]
|
|
|
|
+pub async fn delete_folder(name: String) -> anyhow::Result<()>{
|
|
|
|
+ let mut client = connect_to_imap_server(Config::global().imap_domain.clone() ,993).await?; // TODO move port to config
|
|
|
|
+ client.login(Config::global().username.clone(), Config::global().password.clone()).await?;
|
|
|
|
+ client.delete_folder(name.clone()).await?;
|
|
|
|
+ client.logout().await?;
|
|
|
|
+ Ok(())
|
|
|
|
+}
|
|
|
|
+
|
|
fn store(
|
|
fn store(
|
|
path: PathBuf,
|
|
path: PathBuf,
|
|
uid: String,
|
|
uid: String,
|