review template, write and search commands

This commit is contained in:
Clément DOUIN 2021-09-19 17:21:42 +02:00
parent 079572666a
commit 9931658ea3
No known key found for this signature in database
GPG key ID: 69C9B9CFFDEE2DEF
2 changed files with 17 additions and 5 deletions

View file

@ -354,6 +354,7 @@ pub fn reply<
Ok(())
}
/// Save a raw message to the targetted mailbox.
pub fn save<ImapService: ImapServiceInterface>(
mbox: Option<&str>,
msg: &str,
@ -367,6 +368,7 @@ pub fn save<ImapService: ImapServiceInterface>(
Ok(())
}
/// Search messages from the given IMAP query.
pub fn search<OutputService: OutputServiceInterface, ImapService: ImapServiceInterface>(
page_size: Option<usize>,
page: usize,
@ -388,6 +390,7 @@ pub fn search<OutputService: OutputServiceInterface, ImapService: ImapServiceInt
Ok(())
}
/// Send a raw message.
pub fn send<
OutputService: OutputServiceInterface,
ImapService: ImapServiceInterface,
@ -422,6 +425,7 @@ pub fn send<
Ok(())
}
/// Compose a new message.
pub fn write<
OutputService: OutputServiceInterface,
ImapService: ImapServiceInterface,

View file

@ -79,15 +79,23 @@ fn override_msg_with_args<'a>(msg: &mut Msg, tpl: Tpl<'a>) {
Some(from) => from.map(|arg| arg.to_string()).collect(),
None => msg.headers.from.clone(),
};
let to: Vec<String> = match tpl.to {
Some(to) => to.map(|arg| arg.to_string()).collect(),
None => Vec::new(),
};
let subject = tpl.subject.map(String::from);
let cc: Option<Vec<String>> = tpl.cc.map(|cc| cc.map(|arg| arg.to_string()).collect());
let bcc: Option<Vec<String>> = tpl.bcc.map(|bcc| bcc.map(|arg| arg.to_string()).collect());
let subject = tpl
.subject
.map(String::from)
.or_else(|| msg.headers.subject.clone())
.or_else(|| Some(String::new()));
let cc: Option<Vec<String>> = tpl
.cc
.map(|cc| cc.map(|arg| arg.to_string()).collect())
.or_else(|| msg.headers.cc.clone());
let bcc: Option<Vec<String>> = tpl
.bcc
.map(|bcc| bcc.map(|arg| arg.to_string()).collect())
.or_else(|| msg.headers.bcc.clone());
let custom_headers: Option<HashMap<String, Vec<String>>> = {
if let Some(matched_headers) = tpl.headers {