diff --git a/src/config.rs b/src/config.rs index 12e5277..2e3aad6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -32,7 +32,6 @@ pub(crate) struct Config { } impl Config { - /// Create a new config object from the config.toml file pub(crate) fn new() -> Self { let config_contents = diff --git a/src/discord.rs b/src/discord.rs index 3f00c6c..8316f54 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -59,7 +59,9 @@ pub(crate) async fn send_message( } // Discord only allows a specific size of attachments per message. This size can be set in the config file - if total_attachment_size + attachment.contents.len() > discord_config.attachment_size_limit as usize * 1_000_000 { + if total_attachment_size + attachment.contents.len() + > discord_config.attachment_size_limit as usize * 1_000_000 + { // TODO: Add note to footer that not all attachments are included break; } diff --git a/src/email.rs b/src/email.rs index 9a4ad18..301a497 100644 --- a/src/email.rs +++ b/src/email.rs @@ -1,7 +1,7 @@ +use html2text::from_read; use mail_parser::PartType::{Html, Text}; use mail_parser::{Addr, Address, HeaderName, HeaderValue, MessageParser, MimeHeaders}; use std::borrow::Cow; -use html2text::from_read; /// Email struct that contains all information that will be sent #[derive(Debug)] @@ -57,9 +57,7 @@ pub fn parse_message_to_email(message: Vec) -> Result { println!("Found text body with ID {}:\n{}", i, message_body); Some(message_body) } - Html(message_body) => { - Some(from_read(message_body.as_bytes(), 140).into()) - } + Html(message_body) => Some(from_read(message_body.as_bytes(), 140).into()), _ => None, }) .collect::>>() @@ -114,7 +112,6 @@ pub fn parse_message_to_email(message: Vec) -> Result { .flatten() .collect(); - Ok(Email { to, from, @@ -128,8 +125,7 @@ pub fn parse_message_to_email(message: Vec) -> Result { /// Convert a list of addresses to a list of recipients fn addresses_to_recipients(list: &Vec) -> Vec { - list - .iter() + list.iter() .map(|addr| { let name = addr .name @@ -145,4 +141,4 @@ fn addresses_to_recipients(list: &Vec) -> Vec { Recipient { name, address } }) .collect() -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index d70e4f9..5ab522a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,8 +59,7 @@ async fn courier(config: &Config) -> ImapResult<()> { // Send all emails to Discord for email in emails { - match discord::send_message(&email, &config.discord) - .await { + match discord::send_message(&email, &config.discord).await { Ok(_) => println!("Sent email to Discord!"), Err(e) => println!("Could not send email to Discord: {}", e), }