add flag seen by default for send and save commands

This commit is contained in:
Clément DOUIN 2023-02-23 18:23:15 +01:00
parent 55f5de1803
commit 501c7f18f5
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
3 changed files with 13 additions and 5 deletions

2
Cargo.lock generated
View file

@ -804,7 +804,7 @@ dependencies = [
[[package]]
name = "himalaya-lib"
version = "0.6.0"
source = "git+https://git.sr.ht/~soywod/himalaya-lib?branch=develop#9617be67bcec1f1a80924288be34d3476a260890"
source = "git+https://git.sr.ht/~soywod/himalaya-lib?branch=develop#3d71e3304eb529604f1059c54f8a2a214ab357dc"
dependencies = [
"ammonia",
"chrono",

View file

@ -334,7 +334,7 @@ pub fn send<P: Printer, B: Backend + ?Sized, S: Sender + ?Sized>(
sender: &mut S,
raw_email: String,
) -> Result<()> {
let folder = config.folder_alias("sent")?;
let folder = config.sent_folder_alias()?;
let is_tty = atty::is(Stream::Stdin);
let is_json = printer.is_json();
let raw_email = if is_tty || is_json {
@ -349,7 +349,11 @@ pub fn send<P: Printer, B: Backend + ?Sized, S: Sender + ?Sized>(
};
trace!("raw email: {:?}", raw_email);
sender.send(raw_email.as_bytes())?;
backend.add_email(&folder, raw_email.as_bytes(), &Flags::default())?;
backend.add_email(
&folder,
raw_email.as_bytes(),
&Flags::from_iter([Flag::Seen]),
)?;
Ok(())
}

View file

@ -81,7 +81,7 @@ pub fn edit_tpl_with_editor<P: Printer, B: Backend + ?Sized, S: Sender + ?Sized>
sender.send(&email)?;
let sent_folder = config.sent_folder_alias()?;
printer.print_log(format!("Adding email to the {} folder…", sent_folder))?;
backend.add_email(&sent_folder, &email, &Flags::default())?;
backend.add_email(&sent_folder, &email, &Flags::from_iter([Flag::Seen]))?;
remove_local_draft()?;
printer.print("Done!")?;
break;
@ -101,7 +101,11 @@ pub fn edit_tpl_with_editor<P: Printer, B: Backend + ?Sized, S: Sender + ?Sized>
.some_pgp_sign_cmd(config.email_writing_sign_cmd.as_ref())
.some_pgp_encrypt_cmd(config.email_writing_encrypt_cmd.as_ref()),
)?;
backend.add_email(&draft_folder, &email, &Flags::from_iter([Flag::Draft]))?;
backend.add_email(
&draft_folder,
&email,
&Flags::from_iter([Flag::Seen, Flag::Draft]),
)?;
remove_local_draft()?;
printer.print(format!("Email successfully saved to {}", draft_folder))?;
break;