Yurii Sokolovskyi 3 сар өмнө
parent
commit
692e864287
1 өөрчлөгдсөн 8 нэмэгдсэн , 8 устгасан
  1. 8 8
      src/imap.rs

+ 8 - 8
src/imap.rs

@@ -251,7 +251,7 @@ fn update_local_uids(uid: String, list: String, uids_path: PathBuf) -> io::Resul
 
 #[cfg(target_os = "wasi")]
 pub async fn delete_email_by_uid(list: String, uid: u32) -> anyhow::Result<()>{
-    let mut client = connect_to_imap_server(Config::global().imap_domain.clone() ,993).await?; // TODO move port to config
+    let mut client = connect_to_imap_server(Config::global().imap_domain.clone(), Config::global().imap_port.clone() as u16).await?;
     client.login(Config::global().username.clone(), Config::global().password.clone()).await?;
     client.select(list.clone()).await?;
     client.mark_deleted(uid).await?;
@@ -263,7 +263,7 @@ pub async fn delete_email_by_uid(list: String, uid: u32) -> anyhow::Result<()>{
 #[cfg(not(target_os = "wasi"))]
 pub async fn delete_email_by_uid(list: String, uid: u32) -> 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 client = imap::connect((Config::global().imap_domain.clone(), Config::global().imap_port.clone() as u16), 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)?;
@@ -279,7 +279,7 @@ pub async fn delete_email_by_uid(list: String, uid: u32) -> anyhow::Result<()>{
 #[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 client = imap::connect((Config::global().imap_domain.clone(), Config::global().imap_port.clone() as u16), 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)?;
@@ -292,7 +292,7 @@ pub async fn create_folder(name: String) -> anyhow::Result<()>{
 
 #[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
+    let mut client = connect_to_imap_server(Config::global().imap_domain.clone(), Config::global().imap_port.clone() as u16).await?;
     client.login(Config::global().username.clone(), Config::global().password.clone()).await?;
     client.create_folder(name.clone()).await?;
     client.logout().await?;
@@ -302,7 +302,7 @@ pub async fn create_folder(name: String) -> anyhow::Result<()>{
 #[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 client = imap::connect((Config::global().imap_domain.clone(), Config::global().imap_port.clone() as u16), 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)?;
@@ -315,7 +315,7 @@ pub async fn rename_folder(name: String, new_name: String) -> anyhow::Result<()>
 
 #[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
+    let mut client = connect_to_imap_server(Config::global().imap_domain.clone(), Config::global().imap_port.clone() as u16).await?;
     client.login(Config::global().username.clone(), Config::global().password.clone()).await?;
     client.rename_folder(name.clone(), new_name.clone()).await?;
     client.logout().await?;
@@ -325,7 +325,7 @@ pub async fn rename_folder(name: String, new_name: String) -> anyhow::Result<()>
 #[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 client = imap::connect((Config::global().imap_domain.clone(), Config::global().imap_port.clone() as u16), 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)?;
@@ -338,7 +338,7 @@ pub async fn delete_folder(name: String) -> anyhow::Result<()>{
 
 #[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
+    let mut client = connect_to_imap_server(Config::global().imap_domain.clone(), Config::global().imap_port.clone() as u16).await?;
     client.login(Config::global().username.clone(), Config::global().password.clone()).await?;
     client.delete_folder(name.clone()).await?;
     client.logout().await?;