summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-01-02 20:50:06 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-01-03 10:17:24 +0100
commitd80ef3bb7906a3adef8a3318a0051e6ebb742284 (patch)
treea458a785c60740ad5a5c9fd4820b0007491274e3
parent0122e59bb073a4bee0e74f6d1e09c32e077dc249 (diff)
Remove feature to print content as well
When _list_ing a list of mails, we should not show the content at all. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--bin/domain/imag-mail/src/lib.rs47
-rw-r--r--bin/domain/imag-mail/src/ui.rs8
2 files changed, 9 insertions, 46 deletions
diff --git a/bin/domain/imag-mail/src/lib.rs b/bin/domain/imag-mail/src/lib.rs
index 0dd7f2bb..eb0f68b6 100644
--- a/bin/domain/imag-mail/src/lib.rs
+++ b/bin/domain/imag-mail/src/lib.rs
@@ -143,17 +143,6 @@ fn import_mail(rt: &Runtime) -> Result<()> {
fn list(rt: &Runtime) -> Result<()> {
let refconfig = get_ref_config(rt, "imag-mail")?;
let scmd = rt.cli().subcommand_matches("list").unwrap(); // safe via clap
- let print_content = scmd.is_present("list-read");
-
- if print_content {
- // TODO: Check whether workaround with "{}" is still necessary when updating "indoc"
- warn!("{}", indoc!(r#"You requested to print the content of the mail as well.
- We use the 'mailparse' crate underneath, but its implementation is nonoptimal.
- Thus, the content might be printed as empty (no text in the email)
- This is not reliable and might be wrong."#));
-
- // TODO: Fix above.
- }
// TODO: Implement lister type in libimagmail for this
//
@@ -161,8 +150,7 @@ fn list(rt: &Runtime) -> Result<()> {
// way we do not call get_ref_config() multiple times.
fn list_mail<'a>(rt: &Runtime,
refconfig: &::libimagentryref::reference::Config,
- m: &FileLockEntry<'a>,
- print_content: bool) -> Result<()> {
+ m: &FileLockEntry<'a>) -> Result<()> {
let id = match m.get_message_id(&refconfig)? {
Some(f) => f.into(),
@@ -184,30 +172,13 @@ fn list(rt: &Runtime) -> Result<()> {
None => "<no subject>".to_owned(),
};
- if print_content {
- use libimagmail::hasher::MailHasher;
-
- let content = m.as_ref_with_hasher::<MailHasher>()
- .get_path(&refconfig)
- .and_then(util::get_mail_text_content)?;
-
- writeln!(rt.stdout(),
- "Mail: {id}\nFrom: {from}\nTo: {to}\n{subj}\n---\n{content}\n---\n",
- from = from,
- id = id,
- subj = subject,
- to = to,
- content = content
- )?;
- } else {
- writeln!(rt.stdout(),
- "Mail: {id}\nFrom: {from}\nTo: {to}\n{subj}\n",
- from = from,
- id = id,
- subj = subject,
- to = to
- )?;
- }
+ writeln!(rt.stdout(),
+ "Mail: {id}\nFrom: {from}\nTo: {to}\n{subj}\n",
+ from = from,
+ id = id,
+ subj = subject,
+ to = to
+ )?;
rt.report_touched(m.get_location())?;
Ok(())
@@ -229,7 +200,7 @@ fn list(rt: &Runtime) -> Result<()> {
.inspect(|id| debug!("Found: {:?}", id))
.into_get_iter(rt.store())
.map_inner_ok_or_else(|| err_msg("Did not find one entry"))
- .and_then_ok(|m| list_mail(&rt, &refconfig, &m, print_content))
+ .and_then_ok(|m| list_mail(&rt, &refconfig, &m))
.collect::<Result<Vec<_>>>()
.map(|_| ())
}
diff --git a/bin/domain/imag-mail/src/ui.rs b/bin/domain/imag-mail/src/ui.rs
index e1fa88e6..c51ecdb6 100644
--- a/bin/domain/imag-mail/src/ui.rs
+++ b/bin/domain/imag-mail/src/ui.rs
@@ -51,14 +51,6 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.about("List all stored references to mails")
.version("0.1")
- .arg(Arg::with_name("list-read")
- .long("read")
- .short("r")
- .takes_value(false)
- .required(false)
- .multiple(false)
- .help("Print the textual content of the mail itself as well"))
-
.arg(Arg::with_name("list-id")
.index(1)
.takes_value(true)