del unused crust
This commit is contained in:
parent
daa53a059d
commit
3bbfd34ea9
52
src/main.rs
52
src/main.rs
|
@ -9,8 +9,6 @@ extern crate xdg;
|
|||
use native_tls::{TlsConnector, TlsStream};
|
||||
use rayon::prelude::*;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::net::TcpStream;
|
||||
|
@ -105,56 +103,6 @@ impl<T: Read + Write + imap::extensions::idle::SetReadTimeout> Connection<T> {
|
|||
}
|
||||
last_notified = std::cmp::max(last_notified, uids.iter().cloned().max().unwrap_or(0));
|
||||
|
||||
let mut subjects = BTreeMap::new();
|
||||
if !uids.is_empty() {
|
||||
let uids: Vec<_> = uids.into_iter().map(|v: u32| format!("{}", v)).collect();
|
||||
for msg in self.socket
|
||||
.uid_fetch(&uids.join(","), "RFC822.HEADER")?
|
||||
.iter()
|
||||
{
|
||||
let msg = msg.header();
|
||||
if msg.is_none() {
|
||||
continue;
|
||||
}
|
||||
|
||||
match mailparse::parse_headers(msg.unwrap()) {
|
||||
Ok((headers, _)) => {
|
||||
use mailparse::MailHeaderMap;
|
||||
|
||||
let subject = match headers.get_first_value("Subject") {
|
||||
Ok(Some(subject)) => Cow::from(subject),
|
||||
Ok(None) => Cow::from("<no subject>"),
|
||||
Err(e) => {
|
||||
println!("failed to get message subject: {:?}", e);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
let date = match headers.get_first_value("Date") {
|
||||
Ok(Some(date)) => {
|
||||
match chrono::DateTime::parse_from_rfc2822(&date) {
|
||||
Ok(date) => date.with_timezone(&chrono::Local),
|
||||
Err(e) => {
|
||||
println!("failed to parse message date: {:?}", e);
|
||||
chrono::Local::now()
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(None) => chrono::Local::now(),
|
||||
Err(e) => {
|
||||
println!("failed to get message date: {:?}", e);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
subjects.insert(date, subject);
|
||||
}
|
||||
Err(e) => println!("failed to parse headers of message: {:?}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tx.send((account, num_unseen)).unwrap();
|
||||
|
||||
// IDLE until we see changes
|
||||
|
|
Loading…
Reference in New Issue
Block a user