Skip to content

Commit

Permalink
chore: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mfloto committed Dec 30, 2023
1 parent e8d5b9e commit 4253b82
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 3 additions & 1 deletion src/discord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 4 additions & 8 deletions src/email.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -57,9 +57,7 @@ pub fn parse_message_to_email(message: Vec<u8>) -> Result<Email, &'static str> {
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::<Vec<Cow<'_, str>>>()
Expand Down Expand Up @@ -114,7 +112,6 @@ pub fn parse_message_to_email(message: Vec<u8>) -> Result<Email, &'static str> {
.flatten()
.collect();


Ok(Email {
to,
from,
Expand All @@ -128,8 +125,7 @@ pub fn parse_message_to_email(message: Vec<u8>) -> Result<Email, &'static str> {

/// Convert a list of addresses to a list of recipients
fn addresses_to_recipients(list: &Vec<Addr>) -> Vec<Recipient> {
list
.iter()
list.iter()
.map(|addr| {
let name = addr
.name
Expand All @@ -145,4 +141,4 @@ fn addresses_to_recipients(list: &Vec<Addr>) -> Vec<Recipient> {
Recipient { name, address }
})
.collect()
}
}
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down

0 comments on commit 4253b82

Please sign in to comment.