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:
parent
7d270815da
commit
1adcf95a19
1 changed files with 3 additions and 3 deletions
|
@ -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()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue