mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 05:07:55 +08:00
fix imap credentials and pgp
This commit is contained in:
+15
-7
@@ -162,13 +162,21 @@ impl BackendBuilder {
|
||||
.map(|mdir_config| MaildirSessionBuilder::new(account_config.clone(), mdir_config)),
|
||||
|
||||
#[cfg(feature = "imap-backend")]
|
||||
imap: toml_account_config
|
||||
.imap
|
||||
.as_ref()
|
||||
.filter(|_| is_imap_used)
|
||||
.map(|imap_config| {
|
||||
ImapSessionBuilder::new(account_config.clone(), imap_config.clone())
|
||||
}),
|
||||
imap: {
|
||||
let ctx_builder = toml_account_config
|
||||
.imap
|
||||
.as_ref()
|
||||
.filter(|_| is_imap_used)
|
||||
.map(|imap_config| {
|
||||
ImapSessionBuilder::new(account_config.clone(), imap_config.clone())
|
||||
.with_prebuilt_credentials()
|
||||
});
|
||||
|
||||
match ctx_builder {
|
||||
Some(ctx_builder) => Some(ctx_builder.await?),
|
||||
None => None,
|
||||
}
|
||||
},
|
||||
#[cfg(feature = "notmuch-backend")]
|
||||
notmuch: toml_account_config
|
||||
.notmuch
|
||||
|
||||
+25
-2
@@ -537,10 +537,33 @@ pub enum FolderSyncStrategyDef {
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(remote = "Option<PgpConfig>", from = "OptionPgpConfig")]
|
||||
pub struct OptionPgpConfigDef;
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct OptionPgpConfig {
|
||||
#[serde(default, skip)]
|
||||
is_none: bool,
|
||||
#[serde(flatten, with = "PgpConfigDef")]
|
||||
inner: PgpConfig,
|
||||
}
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
impl From<OptionPgpConfig> for Option<PgpConfig> {
|
||||
fn from(config: OptionPgpConfig) -> Option<PgpConfig> {
|
||||
if config.is_none {
|
||||
None
|
||||
} else {
|
||||
Some(config.inner)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(remote = "PgpConfig", tag = "backend", rename_all = "kebab-case")]
|
||||
pub enum PgpConfigDef {
|
||||
#[default]
|
||||
None,
|
||||
#[cfg(feature = "pgp-commands")]
|
||||
#[serde(with = "CmdsPgpConfigDef", alias = "commands")]
|
||||
Cmds(CmdsPgpConfig),
|
||||
|
||||
@@ -77,10 +77,11 @@ pub async fn save<P: Printer>(
|
||||
.join("\n")
|
||||
};
|
||||
|
||||
let compiler = MmlCompilerBuilder::new();
|
||||
#[allow(unused_mut)]
|
||||
let mut compiler = MmlCompilerBuilder::new();
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
let compiler = compiler.with_pgp(config.pgp.clone());
|
||||
compiler.set_some_pgp(config.pgp.clone());
|
||||
|
||||
let email = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
|
||||
|
||||
@@ -108,10 +109,11 @@ pub async fn send<P: Printer>(
|
||||
.join("\n")
|
||||
};
|
||||
|
||||
let compiler = MmlCompilerBuilder::new();
|
||||
#[allow(unused_mut)]
|
||||
let mut compiler = MmlCompilerBuilder::new();
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
let compiler = compiler.with_pgp(config.pgp.clone());
|
||||
compiler.set_some_pgp(config.pgp.clone());
|
||||
|
||||
let email = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
|
||||
|
||||
|
||||
+6
-4
@@ -77,10 +77,11 @@ pub async fn edit_tpl_with_editor<P: Printer>(
|
||||
Ok(PostEditChoice::Send) => {
|
||||
printer.print_log("Sending email…")?;
|
||||
|
||||
let compiler = MmlCompilerBuilder::new();
|
||||
#[allow(unused_mut)]
|
||||
let mut compiler = MmlCompilerBuilder::new();
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
let compiler = compiler.with_pgp(config.pgp.clone());
|
||||
compiler.set_some_pgp(config.pgp.clone());
|
||||
|
||||
let email = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
|
||||
|
||||
@@ -107,10 +108,11 @@ pub async fn edit_tpl_with_editor<P: Printer>(
|
||||
break;
|
||||
}
|
||||
Ok(PostEditChoice::RemoteDraft) => {
|
||||
let compiler = MmlCompilerBuilder::new();
|
||||
#[allow(unused_mut)]
|
||||
let mut compiler = MmlCompilerBuilder::new();
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
let compiler = compiler.with_pgp(config.pgp.clone());
|
||||
compiler.set_some_pgp(config.pgp.clone());
|
||||
|
||||
let email = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user