refactor configs to match new nested api from lib

This commit is contained in:
Clément DOUIN
2023-12-11 18:38:00 +01:00
parent 8e05be7f77
commit 2e0ec913cf
23 changed files with 214 additions and 292 deletions
+9 -8
View File
@@ -44,8 +44,8 @@ impl AccountConfigureCommand {
#[cfg(feature = "imap")]
if let Some(ref config) = account_config.imap {
let reset = match &config.auth {
ImapAuthConfig::Passwd(config) => config.reset(),
ImapAuthConfig::OAuth2(config) => config.reset(),
ImapAuthConfig::Passwd(config) => config.reset().await,
ImapAuthConfig::OAuth2(config) => config.reset().await,
};
if let Err(err) = reset {
warn!("error while resetting imap secrets: {err}");
@@ -56,8 +56,8 @@ impl AccountConfigureCommand {
#[cfg(feature = "smtp")]
if let Some(ref config) = account_config.smtp {
let reset = match &config.auth {
SmtpAuthConfig::Passwd(config) => config.reset(),
SmtpAuthConfig::OAuth2(config) => config.reset(),
SmtpAuthConfig::Passwd(config) => config.reset().await,
SmtpAuthConfig::OAuth2(config) => config.reset().await,
};
if let Err(err) = reset {
warn!("error while resetting smtp secrets: {err}");
@@ -67,7 +67,7 @@ impl AccountConfigureCommand {
#[cfg(feature = "pgp")]
if let Some(ref config) = account_config.pgp {
account_config.pgp.reset().await?;
config.reset().await?;
}
}
@@ -100,10 +100,11 @@ impl AccountConfigureCommand {
}
#[cfg(feature = "pgp")]
if let Some(ref config) = config.pgp {
if let Some(ref config) = account_config.pgp {
config
.pgp
.configure(&config.email, || prompt_passwd("PGP secret key password"))
.configure(&account_config.email, || {
prompt_passwd("PGP secret key password")
})
.await?;
}
+1 -4
View File
@@ -28,10 +28,7 @@ impl AccountListCommand {
printer.print_table(
Box::new(accounts),
PrintTableOpts {
format: config
.email_reading_format
.as_ref()
.unwrap_or(&Default::default()),
format: &Default::default(),
max_width: self.table.max_width,
},
)
+21 -90
View File
@@ -4,26 +4,21 @@
//! account in the accounts section of the user configuration file.
#[cfg(feature = "pgp")]
use email::account::PgpConfig;
use email::account::config::pgp::PgpConfig;
#[cfg(feature = "imap")]
use email::imap::config::ImapConfig;
#[cfg(feature = "smtp")]
use email::smtp::config::SmtpConfig;
use email::{
email::config::{EmailHooks, EmailTextPlainFormat},
folder::sync::FolderSyncStrategy,
maildir::config::MaildirConfig,
account::sync::config::SyncConfig, maildir::config::MaildirConfig,
sendmail::config::SendmailConfig,
};
use serde::{Deserialize, Serialize};
use std::{
collections::{HashMap, HashSet},
path::PathBuf,
};
use std::{collections::HashSet, path::PathBuf};
use crate::{
backend::BackendKind, config::prelude::*, envelope::config::EnvelopeConfig,
flag::config::FlagConfig, folder::config::FolderConfig, message::config::MessageConfig,
backend::BackendKind, envelope::config::EnvelopeConfig, flag::config::FlagConfig,
folder::config::FolderConfig, message::config::MessageConfig,
};
/// Represents all existing kind of account config.
@@ -34,93 +29,29 @@ pub struct TomlAccountConfig {
pub email: String,
pub display_name: Option<String>,
pub signature_delim: Option<String>,
pub signature: Option<String>,
pub signature_delim: Option<String>,
pub downloads_dir: Option<PathBuf>,
pub folder_listing_page_size: Option<usize>,
pub folder_aliases: Option<HashMap<String, String>>,
pub email_listing_page_size: Option<usize>,
pub email_listing_datetime_fmt: Option<String>,
pub email_listing_datetime_local_tz: Option<bool>,
pub email_reading_headers: Option<Vec<String>>,
#[serde(
default,
with = "OptionEmailTextPlainFormatDef",
skip_serializing_if = "Option::is_none"
)]
pub email_reading_format: Option<EmailTextPlainFormat>,
pub email_writing_headers: Option<Vec<String>>,
pub email_sending_save_copy: Option<bool>,
#[serde(
default,
with = "OptionEmailHooksDef",
skip_serializing_if = "Option::is_none"
)]
pub email_hooks: Option<EmailHooks>,
pub sync: Option<bool>,
pub sync_dir: Option<PathBuf>,
#[serde(
default,
with = "OptionFolderSyncStrategyDef",
skip_serializing_if = "Option::is_none"
)]
pub sync_folders_strategy: Option<FolderSyncStrategy>,
pub backend: Option<BackendKind>,
pub sync: Option<SyncConfig>,
pub folder: Option<FolderConfig>,
pub envelope: Option<EnvelopeConfig>,
pub flag: Option<FlagConfig>,
pub message: Option<MessageConfig>,
#[cfg(feature = "imap")]
#[serde(
default,
with = "OptionImapConfigDef",
skip_serializing_if = "Option::is_none"
)]
pub imap: Option<ImapConfig>,
#[serde(
default,
with = "OptionMaildirConfigDef",
skip_serializing_if = "Option::is_none"
)]
pub maildir: Option<MaildirConfig>,
#[cfg(feature = "notmuch")]
#[serde(
default,
with = "OptionNotmuchConfigDef",
skip_serializing_if = "Option::is_none"
)]
pub notmuch: Option<NotmuchConfig>,
#[cfg(feature = "smtp")]
#[serde(
default,
with = "OptionSmtpConfigDef",
skip_serializing_if = "Option::is_none"
)]
pub smtp: Option<SmtpConfig>,
#[serde(
default,
with = "OptionSendmailConfigDef",
skip_serializing_if = "Option::is_none"
)]
pub sendmail: Option<SendmailConfig>,
#[cfg(feature = "pgp")]
#[serde(
default,
with = "OptionPgpConfigDef",
skip_serializing_if = "Option::is_none"
)]
pub pgp: Option<PgpConfig>,
pub backend: Option<BackendKind>,
#[cfg(feature = "maildir")]
pub maildir: Option<MaildirConfig>,
#[cfg(feature = "imap")]
pub imap: Option<ImapConfig>,
#[cfg(feature = "notmuch")]
pub notmuch: Option<NotmuchConfig>,
#[cfg(feature = "smtp")]
pub smtp: Option<SmtpConfig>,
#[cfg(feature = "sendmail")]
pub sendmail: Option<SendmailConfig>,
}
impl TomlAccountConfig {
@@ -207,7 +138,7 @@ impl TomlAccountConfig {
pub fn add_raw_message_kind(&self) -> Option<&BackendKind> {
self.message
.as_ref()
.and_then(|msg| msg.add.as_ref())
.and_then(|msg| msg.write.as_ref())
.and_then(|add| add.backend.as_ref())
.or_else(|| self.backend.as_ref())
}
@@ -223,7 +154,7 @@ impl TomlAccountConfig {
pub fn get_messages_kind(&self) -> Option<&BackendKind> {
self.message
.as_ref()
.and_then(|message| message.get.as_ref())
.and_then(|message| message.read.as_ref())
.and_then(|get| get.backend.as_ref())
.or_else(|| self.backend.as_ref())
}
+15 -9
View File
@@ -1,5 +1,6 @@
use anyhow::{bail, Result};
use dialoguer::{Confirm, Input};
use email::account::sync::config::SyncConfig;
use email_address::EmailAddress;
use crate::{
@@ -87,15 +88,20 @@ pub(crate) async fn configure() -> Result<Option<(String, TomlAccountConfig)>> {
_ => (),
};
config.sync = Some(
Confirm::new()
.with_prompt(wizard_prompt!(
"Do you need an offline access to your account?"
))
.default(false)
.interact_opt()?
.unwrap_or_default(),
);
let should_configure_sync = Confirm::new()
.with_prompt(wizard_prompt!(
"Do you need an offline access to your account?"
))
.default(false)
.interact_opt()?
.unwrap_or_default();
if should_configure_sync {
config.sync = Some(SyncConfig {
enable: Some(true),
..Default::default()
});
}
Ok(Some((account_name, config)))
}
+2 -2
View File
@@ -173,7 +173,7 @@ impl BackendBuilder {
MaildirSessionBuilder::new(account_config.clone(), mdir_config.clone())
}),
maildir_for_sync: Some(MaildirConfig {
root_dir: account_config.sync_dir()?,
root_dir: account_config.get_sync_dir()?,
})
.filter(|_| is_maildir_for_sync_used)
.map(|mdir_config| MaildirSessionBuilder::new(account_config.clone(), mdir_config)),
@@ -691,7 +691,7 @@ impl Backend {
id_mapper = IdMapper::new(
&self.backend.account_config,
folder,
self.backend.account_config.sync_dir()?,
self.backend.account_config.get_sync_dir()?,
)?;
}
#[cfg(feature = "notmuch")]
+20 -63
View File
@@ -1,14 +1,12 @@
pub mod args;
pub mod prelude;
pub mod wizard;
use anyhow::{anyhow, Context, Result};
use dialoguer::Confirm;
use dirs::{config_dir, home_dir};
use email::{
account::config::AccountConfig,
config::Config,
email::config::{EmailHooks, EmailTextPlainFormat},
account::config::AccountConfig, config::Config, envelope::config::EnvelopeConfig,
folder::config::FolderConfig, message::config::MessageConfig,
};
use serde::{Deserialize, Serialize};
use shellexpand_utils::{canonicalize, expand};
@@ -20,10 +18,7 @@ use std::{
};
use toml;
use crate::{
account::config::TomlAccountConfig, backend::BackendKind, config::prelude::*, wizard_prompt,
wizard_warn,
};
use crate::{account::config::TomlAccountConfig, backend::BackendKind, wizard_prompt, wizard_warn};
/// Represents the user config file.
#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
@@ -31,32 +26,10 @@ use crate::{
pub struct TomlConfig {
#[serde(alias = "name")]
pub display_name: Option<String>,
pub signature_delim: Option<String>,
pub signature: Option<String>,
pub signature_delim: Option<String>,
pub downloads_dir: Option<PathBuf>,
pub folder_listing_page_size: Option<usize>,
pub folder_aliases: Option<HashMap<String, String>>,
pub email_listing_page_size: Option<usize>,
pub email_listing_datetime_fmt: Option<String>,
pub email_listing_datetime_local_tz: Option<bool>,
pub email_reading_headers: Option<Vec<String>>,
#[serde(
default,
with = "OptionEmailTextPlainFormatDef",
skip_serializing_if = "Option::is_none"
)]
pub email_reading_format: Option<EmailTextPlainFormat>,
pub email_writing_headers: Option<Vec<String>>,
pub email_sending_save_copy: Option<bool>,
#[serde(
default,
with = "OptionEmailHooksDef",
skip_serializing_if = "Option::is_none"
)]
pub email_hooks: Option<EmailHooks>,
#[serde(flatten)]
pub accounts: HashMap<String, TomlAccountConfig>,
}
@@ -203,7 +176,7 @@ impl TomlConfig {
let (account_name, mut toml_account_config) =
self.into_toml_account_config(account_name)?;
if let Some(true) = toml_account_config.sync {
if let Some(true) = toml_account_config.sync.as_ref().and_then(|c| c.enable) {
if !disable_cache {
toml_account_config.backend = Some(BackendKind::MaildirForSync);
}
@@ -211,22 +184,10 @@ impl TomlConfig {
let config = Config {
display_name: self.display_name,
signature_delim: self.signature_delim,
signature: self.signature,
signature_delim: self.signature_delim,
downloads_dir: self.downloads_dir,
folder_listing_page_size: self.folder_listing_page_size,
folder_aliases: self.folder_aliases,
email_listing_page_size: self.email_listing_page_size,
email_listing_datetime_fmt: self.email_listing_datetime_fmt,
email_listing_datetime_local_tz: self.email_listing_datetime_local_tz,
email_reading_headers: self.email_reading_headers,
email_reading_format: self.email_reading_format,
email_writing_headers: self.email_writing_headers,
email_sending_save_copy: self.email_sending_save_copy,
email_hooks: self.email_hooks,
accounts: HashMap::from_iter(self.accounts.clone().into_iter().map(
|(name, config)| {
(
@@ -235,27 +196,23 @@ impl TomlConfig {
name,
email: config.email,
display_name: config.display_name,
signature_delim: config.signature_delim,
signature: config.signature,
signature_delim: config.signature_delim,
downloads_dir: config.downloads_dir,
folder_listing_page_size: config.folder_listing_page_size,
folder_aliases: config.folder_aliases.unwrap_or_default(),
email_listing_page_size: config.email_listing_page_size,
email_listing_datetime_fmt: config.email_listing_datetime_fmt,
email_listing_datetime_local_tz: config.email_listing_datetime_local_tz,
email_reading_headers: config.email_reading_headers,
email_reading_format: config.email_reading_format.unwrap_or_default(),
email_writing_headers: config.email_writing_headers,
email_sending_save_copy: config.email_sending_save_copy,
email_hooks: config.email_hooks.unwrap_or_default(),
sync: config.sync.unwrap_or_default(),
sync_dir: config.sync_dir,
sync_folders_strategy: config.sync_folders_strategy.unwrap_or_default(),
folder: config.folder.map(|c| FolderConfig {
aliases: c.remote.aliases,
list: c.list.map(|c| c.remote),
}),
envelope: config.envelope.map(|c| EnvelopeConfig {
list: c.list.map(|c| c.remote),
}),
message: config.message.map(|c| MessageConfig {
read: c.read.map(|c| c.remote),
write: c.write.map(|c| c.remote),
send: c.send.map(|c| c.remote),
}),
sync: config.sync,
#[cfg(feature = "pgp")]
pgp: config.pgp,
},
+2 -2
View File
@@ -58,7 +58,7 @@ impl EnvelopeListCommand {
let page_size = self
.page_size
.unwrap_or(account_config.email_listing_page_size());
.unwrap_or(account_config.get_envelope_list_page_size());
let page = 1.max(self.page) - 1;
let envelopes = backend.list_envelopes(folder, page_size, page).await?;
@@ -66,7 +66,7 @@ impl EnvelopeListCommand {
printer.print_table(
Box::new(envelopes),
PrintTableOpts {
format: &account_config.email_reading_format,
format: &account_config.get_message_read_format(),
max_width: self.table.max_width,
},
)?;
+3
View File
@@ -28,6 +28,9 @@ impl EnvelopeConfig {
#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
pub struct EnvelopeListConfig {
pub backend: Option<BackendKind>,
#[serde(flatten)]
pub remote: email::envelope::list::config::EnvelopeListConfig,
}
impl EnvelopeListConfig {
@@ -65,12 +65,11 @@ impl AttachmentDownloadCommand {
))?;
for attachment in attachments {
let filename = attachment
let filename: PathBuf = attachment
.filename
.map(PathBuf::from)
.and_then(|f| f.file_name().map(|f| f.to_string_lossy().to_string()))
.unwrap_or_else(|| Uuid::new_v4().to_string());
let filepath = account_config.download_fpath(&filename)?;
.unwrap_or_else(|| Uuid::new_v4().to_string())
.into();
let filepath = account_config.get_download_file_path(&filename)?;
printer.print_log(format!("Downloading {:?}", filepath))?;
fs::write(&filepath, &attachment.body)
.with_context(|| format!("cannot save attachment at {filepath:?}"))?;
+2 -2
View File
@@ -60,7 +60,7 @@ impl MessageMailtoCommand {
}
}
match account_config.signature() {
match account_config.find_full_signature() {
Ok(Some(ref signature)) => builder = builder.text_body(body + "\n\n" + signature),
Ok(None) => builder = builder.text_body(body),
Err(err) => {
@@ -71,7 +71,7 @@ impl MessageMailtoCommand {
let tpl = account_config
.generate_tpl_interpreter()
.with_show_only_headers(account_config.email_writing_headers())
.with_show_only_headers(account_config.get_message_write_headers())
.build()
.from_msg_builder(builder)
.await?;
+2 -2
View File
@@ -35,7 +35,7 @@ impl MessageSendCommand {
let (toml_account_config, account_config) =
config.clone().into_account_configs(account, cache)?;
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
let folder = account_config.sent_folder_alias()?;
let folder = account_config.get_sent_folder_alias()?;
let is_tty = io::stdin().is_terminal();
let is_json = printer.is_json();
@@ -52,7 +52,7 @@ impl MessageSendCommand {
backend.send_raw_message(msg.as_bytes()).await?;
if account_config.email_sending_save_copy.unwrap_or_default() {
if account_config.should_save_copy_sent_message() {
backend
.add_raw_message_with_flag(&folder, msg.as_bytes(), Flag::Seen)
.await?;
+14 -5
View File
@@ -5,12 +5,12 @@ use crate::backend::BackendKind;
#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
pub struct MessageConfig {
pub add: Option<MessageAddConfig>,
pub write: Option<MessageAddConfig>,
pub send: Option<MessageSendConfig>,
pub peek: Option<MessagePeekConfig>,
pub get: Option<MessageGetConfig>,
pub read: Option<MessageGetConfig>,
pub copy: Option<MessageCopyConfig>,
#[serde(default, rename = "move", skip_serializing_if = "Option::is_none")]
#[serde(rename = "move")]
pub move_: Option<MessageMoveConfig>,
}
@@ -18,7 +18,7 @@ impl MessageConfig {
pub fn get_used_backends(&self) -> HashSet<&BackendKind> {
let mut kinds = HashSet::default();
if let Some(add) = &self.add {
if let Some(add) = &self.write {
kinds.extend(add.get_used_backends());
}
@@ -30,7 +30,7 @@ impl MessageConfig {
kinds.extend(peek.get_used_backends());
}
if let Some(get) = &self.get {
if let Some(get) = &self.read {
kinds.extend(get.get_used_backends());
}
@@ -49,6 +49,9 @@ impl MessageConfig {
#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
pub struct MessageAddConfig {
pub backend: Option<BackendKind>,
#[serde(flatten)]
pub remote: email::message::add_raw::config::MessageWriteConfig,
}
impl MessageAddConfig {
@@ -66,6 +69,9 @@ impl MessageAddConfig {
#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
pub struct MessageSendConfig {
pub backend: Option<BackendKind>,
#[serde(flatten)]
pub remote: email::message::send_raw::config::MessageSendConfig,
}
impl MessageSendConfig {
@@ -100,6 +106,9 @@ impl MessagePeekConfig {
#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
pub struct MessageGetConfig {
pub backend: Option<BackendKind>,
#[serde(flatten)]
pub remote: email::message::get::config::MessageReadConfig,
}
impl MessageGetConfig {
+1 -1
View File
@@ -60,7 +60,7 @@ impl TemplateSaveCommand {
let mut compiler = MmlCompilerBuilder::new();
#[cfg(feature = "pgp")]
compiler.set_some_pgp(config.pgp.clone());
compiler.set_some_pgp(account_config.pgp.clone());
let msg = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
backend.add_raw_message(folder, &msg).await?;
+3 -3
View File
@@ -38,7 +38,7 @@ impl TemplateSendCommand {
let (toml_account_config, account_config) =
config.clone().into_account_configs(account, cache)?;
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
let folder = account_config.sent_folder_alias()?;
let folder = account_config.get_sent_folder_alias()?;
let is_tty = io::stdin().is_terminal();
let is_json = printer.is_json();
@@ -57,13 +57,13 @@ impl TemplateSendCommand {
let mut compiler = MmlCompilerBuilder::new();
#[cfg(feature = "pgp")]
compiler.set_some_pgp(config.pgp.clone());
compiler.set_some_pgp(account_config.pgp.clone());
let msg = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
backend.send_raw_message(&msg).await?;
if account_config.email_sending_save_copy.unwrap_or_default() {
if account_config.should_save_copy_sent_message() {
backend
.add_raw_message_with_flag(&folder, &msg, Flag::Seen)
.await?;
+1 -1
View File
@@ -42,7 +42,7 @@ impl FolderListCommand {
printer.print_table(
Box::new(folders),
PrintTableOpts {
format: &account_config.email_reading_format,
format: &account_config.get_message_read_format(),
max_width: self.table.max_width,
},
)?;
+6
View File
@@ -10,6 +10,9 @@ pub struct FolderConfig {
pub expunge: Option<FolderExpungeConfig>,
pub purge: Option<FolderPurgeConfig>,
pub delete: Option<FolderDeleteConfig>,
#[serde(flatten)]
pub remote: email::folder::config::FolderConfig,
}
impl FolderConfig {
@@ -60,6 +63,9 @@ impl FolderAddConfig {
#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
pub struct FolderListConfig {
pub backend: Option<BackendKind>,
#[serde(flatten)]
pub remote: email::folder::list::config::FolderListConfig,
}
impl FolderListConfig {
+8 -4
View File
@@ -89,7 +89,8 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Backend
let config = match secret {
Some(idx) if SECRETS[idx] == KEYRING => {
Secret::new_keyring_entry(format!("{account_name}-imap-passwd"))
.set_keyring_entry_secret(prompt_passwd("IMAP password")?)?;
.set_keyring_entry_secret(prompt_passwd("IMAP password")?)
.await?;
PasswdConfig::default()
}
Some(idx) if SECRETS[idx] == RAW => PasswdConfig {
@@ -130,7 +131,8 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Backend
.with_prompt("IMAP OAuth 2.0 client secret")
.interact()?;
Secret::new_keyring_entry(format!("{account_name}-imap-oauth2-client-secret"))
.set_keyring_entry_secret(&client_secret)?;
.set_keyring_entry_secret(&client_secret)
.await?;
config.auth_url = Input::with_theme(&*THEME)
.with_prompt("IMAP OAuth 2.0 authorization URL")
@@ -210,11 +212,13 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Backend
.await?;
Secret::new_keyring_entry(format!("{account_name}-imap-oauth2-access-token"))
.set_keyring_entry_secret(access_token)?;
.set_keyring_entry_secret(access_token)
.await?;
if let Some(refresh_token) = &refresh_token {
Secret::new_keyring_entry(format!("{account_name}-imap-oauth2-refresh-token"))
.set_keyring_entry_secret(refresh_token)?;
.set_keyring_entry_secret(refresh_token)
.await?;
}
ImapAuthConfig::OAuth2(config)
+8 -4
View File
@@ -89,7 +89,8 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Backend
let config = match secret {
Some(idx) if SECRETS[idx] == KEYRING => {
Secret::new_keyring_entry(format!("{account_name}-smtp-passwd"))
.set_keyring_entry_secret(prompt_passwd("SMTP password")?)?;
.set_keyring_entry_secret(prompt_passwd("SMTP password")?)
.await?;
PasswdConfig::default()
}
Some(idx) if SECRETS[idx] == RAW => PasswdConfig {
@@ -130,7 +131,8 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Backend
.with_prompt("SMTP OAuth 2.0 client secret")
.interact()?;
Secret::new_keyring_entry(format!("{account_name}-smtp-oauth2-client-secret"))
.set_keyring_entry_secret(&client_secret)?;
.set_keyring_entry_secret(&client_secret)
.await?;
config.auth_url = Input::with_theme(&*THEME)
.with_prompt("SMTP OAuth 2.0 authorization URL")
@@ -210,11 +212,13 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Backend
.await?;
Secret::new_keyring_entry(format!("{account_name}-smtp-oauth2-access-token"))
.set_keyring_entry_secret(access_token)?;
.set_keyring_entry_secret(access_token)
.await?;
if let Some(refresh_token) = &refresh_token {
Secret::new_keyring_entry(format!("{account_name}-smtp-oauth2-refresh-token"))
.set_keyring_entry_secret(refresh_token)?;
.set_keyring_entry_secret(refresh_token)
.await?;
}
SmtpAuthConfig::OAuth2(config)
+2 -2
View File
@@ -89,8 +89,8 @@ pub async fn edit_tpl_with_editor<P: Printer>(
backend.send_raw_message(&email).await?;
if config.email_sending_save_copy.unwrap_or_default() {
let sent_folder = config.sent_folder_alias()?;
if config.should_save_copy_sent_message() {
let sent_folder = config.get_sent_folder_alias()?;
printer.print_log(format!("Adding email to the {} folder…", sent_folder))?;
backend
.add_raw_message_with_flag(&sent_folder, &email, Flag::Seen)