mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 05:07:55 +08:00
bump mml-lib@v0.5.0 and email-lib@v0.15.3
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
use email::account::CmdsPgpConfig;
|
||||
#[cfg(feature = "pgp-gpg")]
|
||||
use email::account::GpgConfig;
|
||||
#[cfg(feature = "pgp")]
|
||||
use email::account::PgpConfig;
|
||||
#[cfg(feature = "pgp-native")]
|
||||
use email::account::{NativePgpConfig, NativePgpSecretKey, SignedSecretKey};
|
||||
#[cfg(feature = "notmuch-backend")]
|
||||
@@ -11,7 +13,7 @@ use email::backend::{ImapAuthConfig, ImapConfig};
|
||||
#[cfg(feature = "smtp-sender")]
|
||||
use email::sender::{SmtpAuthConfig, SmtpConfig};
|
||||
use email::{
|
||||
account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig, PgpConfig},
|
||||
account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig},
|
||||
backend::{BackendConfig, MaildirConfig},
|
||||
email::{EmailHooks, EmailTextPlainFormat},
|
||||
folder::sync::FolderSyncStrategy,
|
||||
@@ -402,6 +404,7 @@ pub enum FolderSyncStrategyDef {
|
||||
Exclude(HashSet<String>),
|
||||
}
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(remote = "PgpConfig", tag = "backend", rename_all = "kebab-case")]
|
||||
pub enum PgpConfigDef {
|
||||
|
||||
@@ -3,17 +3,20 @@
|
||||
//! This module contains the raw deserialized representation of an
|
||||
//! account in the accounts section of the user configuration file.
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
use email::account::PgpConfig;
|
||||
#[cfg(feature = "imap-backend")]
|
||||
use email::backend::ImapAuthConfig;
|
||||
#[cfg(feature = "smtp-sender")]
|
||||
use email::sender::SmtpAuthConfig;
|
||||
use email::{
|
||||
account::{AccountConfig, PgpConfig},
|
||||
account::AccountConfig,
|
||||
backend::BackendConfig,
|
||||
email::{EmailHooks, EmailTextPlainFormat},
|
||||
folder::sync::FolderSyncStrategy,
|
||||
sender::SenderConfig,
|
||||
};
|
||||
|
||||
use process::Cmd;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
@@ -91,6 +94,7 @@ pub struct DeserializedAccountConfig {
|
||||
#[serde(flatten, with = "SenderConfigDef")]
|
||||
pub sender: SenderConfig,
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
#[serde(default, with = "PgpConfigDef")]
|
||||
pub pgp: PgpConfig,
|
||||
}
|
||||
@@ -221,6 +225,7 @@ impl DeserializedAccountConfig {
|
||||
|
||||
sender
|
||||
},
|
||||
#[cfg(feature = "pgp")]
|
||||
pgp: self.pgp.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ pub async fn configure(config: &AccountConfig, reset: bool) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
config.pgp.reset().await?;
|
||||
}
|
||||
|
||||
@@ -104,6 +105,7 @@ pub async fn configure(config: &AccountConfig, reset: bool) -> Result<()> {
|
||||
}?;
|
||||
}
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
config
|
||||
.pgp
|
||||
.configure(&config.email, || prompt_passwd("PGP secret key password"))
|
||||
|
||||
@@ -186,7 +186,8 @@ pub async fn mailto<P: Printer>(
|
||||
let tpl = config
|
||||
.generate_tpl_interpreter()
|
||||
.with_show_only_headers(config.email_writing_headers())
|
||||
.interpret_msg_builder(builder)
|
||||
.build()
|
||||
.from_msg_builder(builder)
|
||||
.await?;
|
||||
|
||||
editor::edit_tpl_with_editor(config, printer, backend, sender, tpl).await
|
||||
|
||||
+16
-14
@@ -6,7 +6,7 @@ use email::{
|
||||
email::{Flag, Flags, Message},
|
||||
sender::Sender,
|
||||
};
|
||||
use mml::MmlCompiler;
|
||||
use mml::MmlCompilerBuilder;
|
||||
use std::io::{stdin, BufRead};
|
||||
|
||||
use crate::{printer::Printer, IdMapper};
|
||||
@@ -70,14 +70,14 @@ pub async fn reply<P: Printer>(
|
||||
}
|
||||
|
||||
pub async fn save<P: Printer>(
|
||||
config: &AccountConfig,
|
||||
#[allow(unused_variables)] config: &AccountConfig,
|
||||
printer: &mut P,
|
||||
id_mapper: &IdMapper,
|
||||
backend: &mut dyn Backend,
|
||||
folder: &str,
|
||||
tpl: String,
|
||||
) -> Result<()> {
|
||||
let mml = if atty::is(Stream::Stdin) || printer.is_json() {
|
||||
let tpl = if atty::is(Stream::Stdin) || printer.is_json() {
|
||||
tpl.replace("\r", "")
|
||||
} else {
|
||||
stdin()
|
||||
@@ -88,11 +88,12 @@ pub async fn save<P: Printer>(
|
||||
.join("\n")
|
||||
};
|
||||
|
||||
let email = MmlCompiler::new()
|
||||
.with_pgp(config.pgp.clone())
|
||||
.compile(mml)
|
||||
.await?
|
||||
.write_to_vec()?;
|
||||
let compiler = MmlCompilerBuilder::new();
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
let compiler = compiler.with_pgp(config.pgp.clone());
|
||||
|
||||
let email = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
|
||||
|
||||
let id = backend.add_email(folder, &email, &Flags::default()).await?;
|
||||
id_mapper.create_alias(id)?;
|
||||
@@ -109,7 +110,7 @@ pub async fn send<P: Printer>(
|
||||
) -> Result<()> {
|
||||
let folder = config.sent_folder_alias()?;
|
||||
|
||||
let mml = if atty::is(Stream::Stdin) || printer.is_json() {
|
||||
let tpl = if atty::is(Stream::Stdin) || printer.is_json() {
|
||||
tpl.replace("\r", "")
|
||||
} else {
|
||||
stdin()
|
||||
@@ -120,11 +121,12 @@ pub async fn send<P: Printer>(
|
||||
.join("\n")
|
||||
};
|
||||
|
||||
let email = MmlCompiler::new()
|
||||
.with_pgp(config.pgp.clone())
|
||||
.compile(mml)
|
||||
.await?
|
||||
.write_to_vec()?;
|
||||
let compiler = MmlCompilerBuilder::new();
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
let compiler = compiler.with_pgp(config.pgp.clone());
|
||||
|
||||
let email = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
|
||||
|
||||
sender.send(&email).await?;
|
||||
|
||||
|
||||
+18
-11
@@ -6,7 +6,7 @@ use email::{
|
||||
sender::Sender,
|
||||
};
|
||||
use log::debug;
|
||||
use mml::MmlCompiler;
|
||||
use mml::MmlCompilerBuilder;
|
||||
use process::Cmd;
|
||||
use std::{env, fs};
|
||||
|
||||
@@ -78,12 +78,16 @@ pub async fn edit_tpl_with_editor<P: Printer>(
|
||||
match choice::post_edit() {
|
||||
Ok(PostEditChoice::Send) => {
|
||||
printer.print_log("Sending email…")?;
|
||||
let email = MmlCompiler::new()
|
||||
.with_pgp(config.pgp.clone())
|
||||
.compile(tpl)
|
||||
.await?
|
||||
.write_to_vec()?;
|
||||
|
||||
let compiler = MmlCompilerBuilder::new();
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
let compiler = compiler.with_pgp(config.pgp.clone());
|
||||
|
||||
let email = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
|
||||
|
||||
sender.send(&email).await?;
|
||||
|
||||
if config.email_sending_save_copy {
|
||||
let sent_folder = config.sent_folder_alias()?;
|
||||
printer.print_log(format!("Adding email to the {} folder…", sent_folder))?;
|
||||
@@ -91,6 +95,7 @@ pub async fn edit_tpl_with_editor<P: Printer>(
|
||||
.add_email(&sent_folder, &email, &Flags::from_iter([Flag::Seen]))
|
||||
.await?;
|
||||
}
|
||||
|
||||
remove_local_draft()?;
|
||||
printer.print("Done!")?;
|
||||
break;
|
||||
@@ -104,11 +109,13 @@ pub async fn edit_tpl_with_editor<P: Printer>(
|
||||
break;
|
||||
}
|
||||
Ok(PostEditChoice::RemoteDraft) => {
|
||||
let email = MmlCompiler::new()
|
||||
.with_pgp(config.pgp.clone())
|
||||
.compile(tpl)
|
||||
.await?
|
||||
.write_to_vec()?;
|
||||
let compiler = MmlCompilerBuilder::new();
|
||||
|
||||
#[cfg(feature = "pgp")]
|
||||
let compiler = compiler.with_pgp(config.pgp.clone());
|
||||
|
||||
let email = compiler.build(tpl.as_str())?.compile().await?.into_vec()?;
|
||||
|
||||
backend
|
||||
.add_email(
|
||||
"drafts",
|
||||
|
||||
Reference in New Issue
Block a user