Dont panic incase the message couldnt be parsed

Supply defaults to make the loop continue parsing

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2021-07-09 11:03:40 +00:00
parent 7d270815da
commit 1adcf95a19
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -30,9 +30,9 @@ fn fetch_inbox_top() -> imap::error::Result<Option<String>> {
} else {
return Ok(None);
};
let body = message.body().expect("message did not have a body!");
let body = message.body().unwrap_or("NULL".as_bytes());
let body = std::str::from_utf8(body)
.expect("message was not valid utf-8")
.unwrap_or("NULL")
.to_string();
let re = Regex::new(r"(insert string in message body, even 1 matching would do)+").unwrap();
if re.is_match(&body) {
@ -46,4 +46,4 @@ fn fetch_inbox_top() -> imap::error::Result<Option<String>> {
imap_session.expunge().unwrap();
imap_session.logout()?;
Ok(Some("logout".to_string()))
}
}