|
@@ -334,9 +334,14 @@ pub async fn check_for_updates(mailbox: String) -> anyhow::Result<()> {
|
|
|
|
|
|
match idle_wait.await.unwrap() {
|
|
|
NewData(data) => {
|
|
|
- let s = String::from_utf8(data.borrow_owner().to_vec()).unwrap();
|
|
|
- println!("IDLE data:\n{}", s);
|
|
|
- // Process the data as needed here
|
|
|
+ // TODO do not update all emails (IMAP returns * {number} RECENT) and do it only for one mailbox
|
|
|
+ let new_paths = download_email_from_imap().await.expect("Cannot download new emails");
|
|
|
+ for (uid, path) in new_paths.clone() {
|
|
|
+ match add_email(path.clone(), uid.clone()){
|
|
|
+ Ok(_) => {}
|
|
|
+ Err(_) => {println!("Error adding email from {:?}", path.clone())}
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
reason => {
|
|
|
println!("IDLE failed {:?}", reason);
|