bump pimalaya core v1

This commit is contained in:
Clément DOUIN 2024-10-24 15:21:13 +02:00
parent a0dea19cdf
commit 3b271c3e67
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
7 changed files with 501 additions and 781 deletions

1047
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -21,12 +21,10 @@ default = [
"maildir", "maildir",
#"notmuch", #"notmuch",
"smtp", "smtp",
"sendmail", #"sendmail",
#"keyring", #"keyring",
#"oauth2", #"oauth2",
"wizard", "wizard",
#"pgp-commands", #"pgp-commands",
#"pgp-gpg", #"pgp-gpg",
#"pgp-native", #"pgp-native",
@ -38,14 +36,14 @@ notmuch = ["email-lib/notmuch", "pimalaya-tui/notmuch"]
smtp = ["email-lib/smtp", "pimalaya-tui/smtp"] smtp = ["email-lib/smtp", "pimalaya-tui/smtp"]
sendmail = ["email-lib/sendmail", "pimalaya-tui/sendmail"] sendmail = ["email-lib/sendmail", "pimalaya-tui/sendmail"]
keyring = ["email-lib/keyring", "pimalaya-tui/keyring", "secret-lib?/keyring-tokio"] keyring = ["email-lib/keyring", "pimalaya-tui/keyring", "secret-lib/keyring"]
oauth2 = ["dep:oauth-lib", "email-lib/oauth2", "pimalaya-tui/oauth2", "keyring"] oauth2 = ["dep:oauth-lib", "email-lib/oauth2", "pimalaya-tui/oauth2", "keyring"]
wizard = ["dep:email_address", "dep:secret-lib", "email-lib/autoconfig", "pimalaya-tui/wizard"] wizard = ["dep:email_address", "email-lib/autoconfig", "pimalaya-tui/wizard"]
pgp = [] pgp = []
pgp-commands = ["email-lib/pgp-commands", "mml-lib/pgp-commands", "pgp"] pgp-commands = ["email-lib/pgp-commands", "mml-lib/pgp-commands", "pimalaya-tui/pgp-commands", "pgp"]
pgp-gpg = ["email-lib/pgp-gpg", "mml-lib/pgp-gpg", "pgp"] pgp-gpg = ["email-lib/pgp-gpg", "mml-lib/pgp-gpg", "pimalaya-tui/pgp-gpg", "pgp"]
pgp-native = ["email-lib/pgp-native", "mml-lib/pgp-native", "pgp"] pgp-native = ["email-lib/pgp-native", "mml-lib/pgp-native", "pimalaya-tui/pgp-native", "pgp"]
[dependencies] [dependencies]
ariadne = "0.2" ariadne = "0.2"
@ -57,17 +55,17 @@ color-eyre = "0.6"
comfy-table = "7.1" comfy-table = "7.1"
crossterm = { version = "0.27", features = ["serde"] } crossterm = { version = "0.27", features = ["serde"] }
dirs = "4" dirs = "4"
email-lib = { version = "=0.25.0", default-features = false, features = ["derive", "thread", "tracing"] } email-lib = { version = "1", default-features = false, features = ["tokio-rustls", "derive", "thread"] }
email_address = { version = "0.2", optional = true } email_address = { version = "0.2", optional = true }
mail-builder = "0.3" mail-builder = "0.3"
md5 = "0.7" md5 = "0.7"
mml-lib = { version = "=1.0.14", default-features = false, features = ["derive"] } mml-lib = { version = "1", default-features = false, features = ["derive"] }
oauth-lib = { version = "=0.1.1", optional = true } oauth-lib = { version = "1", optional = true }
once_cell = "1.16" once_cell = "1.16"
petgraph = "0.6" petgraph = "0.6"
pimalaya-tui = { version = "=0.1.0", default-features = false, features = ["email", "path", "cli", "himalaya", "tracing", "sled"] } pimalaya-tui = { version = "1", default-features = false, features = ["email", "path", "cli", "himalaya", "tracing", "sled"] }
process-lib = { version = "=0.4.2", features = ["derive"] } process-lib = { version = "1", features = ["derive"] }
secret-lib = { version = "=0.4.6", default-features = false, features = ["command", "derive"], optional = true } secret-lib = { version = "1", default-features = false, features = ["tokio", "rustls", "command", "derive"] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = "1" serde_json = "1"
shellexpand-utils = "=0.2.1" shellexpand-utils = "=0.2.1"
@ -79,18 +77,16 @@ uuid = { version = "0.8", features = ["v4"] }
[patch.crates-io] [patch.crates-io]
# IMAP # IMAP
imap-codec = { git = "https://github.com/duesee/imap-codec" }
imap-next = { git = "https://github.com/duesee/imap-next" } imap-next = { git = "https://github.com/duesee/imap-next" }
imap-client = { git = "https://github.com/pimalaya/imap-client" } imap-client = { git = "https://github.com/pimalaya/imap-client" }
# Pimalaya core # Pimalaya core
#email-lib = { git = "https://github.com/pimalaya/core" } email-lib = { git = "https://github.com/pimalaya/core" }
email-lib = { path = "/home/soywod/code/pimalaya/core/email" } mml-lib = { git = "https://github.com/pimalaya/core" }
pgp-lib = { path = "/home/soywod/code/pimalaya/core/pgp" }
keyring-lib = { git = "https://github.com/pimalaya/core" }
oauth-lib = { git = "https://github.com/pimalaya/core" } oauth-lib = { git = "https://github.com/pimalaya/core" }
process-lib = { git = "https://github.com/pimalaya/core" } process-lib = { git = "https://github.com/pimalaya/core" }
secret-lib = { git = "https://github.com/pimalaya/core" } secret-lib = { git = "https://github.com/pimalaya/core" }
# Pimalaya TUI # Pimalaya non-core
#pimalaya-tui = { git = "https://github.com/pimalaya/tui" } pimalaya-tui = { git = "https://github.com/pimalaya/tui" }
pimalaya-tui = { path = "/home/soywod/code/pimalaya/tui" }

View file

@ -13,7 +13,10 @@ use email::notmuch::NotmuchContextBuilder;
use email::sendmail::SendmailContextBuilder; use email::sendmail::SendmailContextBuilder;
#[cfg(feature = "smtp")] #[cfg(feature = "smtp")]
use email::smtp::SmtpContextBuilder; use email::smtp::SmtpContextBuilder;
use pimalaya_tui::terminal::{cli::printer::Printer, config::TomlConfig as _}; use pimalaya_tui::{
himalaya::config::{Backend, SendingBackend},
terminal::{cli::printer::Printer, config::TomlConfig as _},
};
use tracing::info; use tracing::info;
use crate::{account::arg::name::OptionalAccountNameArg, config::TomlConfig}; use crate::{account::arg::name::OptionalAccountNameArg, config::TomlConfig};
@ -42,8 +45,9 @@ impl AccountCheckUpCommand {
printer.log("Checking backend context integrity…")?; printer.log("Checking backend context integrity…")?;
match toml_account_config.backend {
#[cfg(feature = "maildir")] #[cfg(feature = "maildir")]
if let Some(mdir_config) = toml_account_config.maildir { Some(Backend::Maildir(mdir_config)) => {
printer.log("Checking Maildir integrity…")?; printer.log("Checking Maildir integrity…")?;
let ctx = MaildirContextBuilder::new(account_config.clone(), Arc::new(mdir_config)); let ctx = MaildirContextBuilder::new(account_config.clone(), Arc::new(mdir_config));
@ -51,9 +55,8 @@ impl AccountCheckUpCommand {
.check_up() .check_up()
.await?; .await?;
} }
#[cfg(feature = "imap")] #[cfg(feature = "imap")]
if let Some(imap_config) = toml_account_config.imap { Some(Backend::Imap(imap_config)) => {
printer.log("Checking IMAP integrity…")?; printer.log("Checking IMAP integrity…")?;
let ctx = ImapContextBuilder::new(account_config.clone(), Arc::new(imap_config)) let ctx = ImapContextBuilder::new(account_config.clone(), Arc::new(imap_config))
@ -62,29 +65,36 @@ impl AccountCheckUpCommand {
.check_up() .check_up()
.await?; .await?;
} }
#[cfg(feature = "notmuch")] #[cfg(feature = "notmuch")]
if let Some(notmuch_config) = toml_account_config.notmuch { Some(Backend::Notmuch(notmuch_config)) => {
printer.log("Checking Notmuch integrity…")?; printer.log("Checking Notmuch integrity…")?;
let ctx = NotmuchContextBuilder::new(account_config.clone(), Arc::new(notmuch_config)); let ctx =
NotmuchContextBuilder::new(account_config.clone(), Arc::new(notmuch_config));
BackendBuilder::new(account_config.clone(), ctx) BackendBuilder::new(account_config.clone(), ctx)
.check_up() .check_up()
.await?; .await?;
} }
_ => (),
}
let sending_backend = toml_account_config
.message
.and_then(|msg| msg.send)
.and_then(|send| send.backend);
match sending_backend {
#[cfg(feature = "smtp")] #[cfg(feature = "smtp")]
if let Some(smtp_config) = toml_account_config.smtp { Some(SendingBackend::Smtp(smtp_config)) => {
printer.log("Checking SMTP integrity…")?; printer.log("Checking Smtp integrity…")?;
let ctx = SmtpContextBuilder::new(account_config.clone(), Arc::new(smtp_config)); let ctx = SmtpContextBuilder::new(account_config.clone(), Arc::new(smtp_config));
BackendBuilder::new(account_config.clone(), ctx) BackendBuilder::new(account_config.clone(), ctx)
.check_up() .check_up()
.await?; .await?;
} }
#[cfg(feature = "sendmail")] #[cfg(feature = "sendmail")]
if let Some(sendmail_config) = toml_account_config.sendmail { Some(SendingBackend::Sendmail(sendmail_config)) => {
printer.log("Checking Sendmail integrity…")?; printer.log("Checking Sendmail integrity…")?;
let ctx = let ctx =
@ -93,6 +103,8 @@ impl AccountCheckUpCommand {
.check_up() .check_up()
.await?; .await?;
} }
_ => (),
}
printer.out("Checkup successfully completed!") printer.out("Checkup successfully completed!")
} }

View file

@ -40,13 +40,14 @@ impl AccountConfigureCommand {
if self.reset { if self.reset {
#[cfg(feature = "imap")] #[cfg(feature = "imap")]
if let Some(config) = &toml_account_config.imap { {
let reset = match &config.auth { let reset = match toml_account_config.imap_auth_config() {
ImapAuthConfig::Passwd(config) => config.reset().await, Some(ImapAuthConfig::Password(config)) => config.reset().await,
#[cfg(feature = "oauth2")] #[cfg(feature = "oauth2")]
ImapAuthConfig::OAuth2(config) => config.reset().await, Some(ImapAuthConfig::OAuth2(config)) => config.reset().await,
ImapAuthConfig::MissingOAuth2Feature => unreachable!(), _ => Ok(()),
}; };
if let Err(err) = reset { if let Err(err) = reset {
warn!("error while resetting imap secrets: {err}"); warn!("error while resetting imap secrets: {err}");
debug!("error while resetting imap secrets: {err:?}"); debug!("error while resetting imap secrets: {err:?}");
@ -54,12 +55,14 @@ impl AccountConfigureCommand {
} }
#[cfg(feature = "smtp")] #[cfg(feature = "smtp")]
if let Some(config) = &toml_account_config.smtp { {
let reset = match &config.auth { let reset = match toml_account_config.smtp_auth_config() {
SmtpAuthConfig::Passwd(config) => config.reset().await, Some(SmtpAuthConfig::Passwd(config)) => config.reset().await,
#[cfg(feature = "oauth2")] #[cfg(feature = "oauth2")]
SmtpAuthConfig::OAuth2(config) => config.reset().await, Some(SmtpAuthConfig::OAuth2(config)) => config.reset().await,
_ => Ok(()),
}; };
if let Err(err) = reset { if let Err(err) = reset {
warn!("error while resetting smtp secrets: {err}"); warn!("error while resetting smtp secrets: {err}");
debug!("error while resetting smtp secrets: {err:?}"); debug!("error while resetting smtp secrets: {err:?}");
@ -67,50 +70,47 @@ impl AccountConfigureCommand {
} }
#[cfg(feature = "pgp")] #[cfg(feature = "pgp")]
if let Some(ref config) = account_config.pgp { if let Some(config) = &toml_account_config.pgp {
config.reset().await?; config.reset().await?;
} }
} }
#[cfg(feature = "imap")] #[cfg(feature = "imap")]
if let Some(config) = &toml_account_config.imap { match toml_account_config.imap_auth_config() {
match &config.auth { Some(ImapAuthConfig::Password(config)) => {
ImapAuthConfig::Passwd(config) => {
config config
.configure(|| Ok(prompt::password("IMAP password")?)) .configure(|| Ok(prompt::password("IMAP password")?))
.await .await
} }
#[cfg(feature = "oauth2")] #[cfg(feature = "oauth2")]
ImapAuthConfig::OAuth2(config) => { Some(ImapAuthConfig::OAuth2(config)) => {
config config
.configure(|| Ok(prompt::secret("IMAP OAuth 2.0 client secret")?)) .configure(|| Ok(prompt::secret("IMAP OAuth 2.0 client secret")?))
.await .await
} }
ImapAuthConfig::MissingOAuth2Feature => unreachable!(), _ => Ok(()),
}?; }?;
}
#[cfg(feature = "smtp")] #[cfg(feature = "smtp")]
if let Some(config) = &toml_account_config.smtp { match toml_account_config.smtp_auth_config() {
match &config.auth { Some(SmtpAuthConfig::Passwd(config)) => {
SmtpAuthConfig::Passwd(config) => {
config config
.configure(|| Ok(prompt::password("SMTP password")?)) .configure(|| Ok(prompt::password("SMTP password")?))
.await .await
} }
#[cfg(feature = "oauth2")] #[cfg(feature = "oauth2")]
SmtpAuthConfig::OAuth2(config) => { Some(SmtpAuthConfig::OAuth2(config)) => {
config config
.configure(|| Ok(prompt::secret("SMTP OAuth 2.0 client secret")?)) .configure(|| Ok(prompt::secret("SMTP OAuth 2.0 client secret")?))
.await .await
} }
_ => Ok(()),
}?; }?;
}
#[cfg(feature = "pgp")] #[cfg(feature = "pgp")]
if let Some(ref config) = account_config.pgp { if let Some(config) = &toml_account_config.pgp {
config config
.configure(&account_config.email, || { .configure(&toml_account_config.email, || {
Ok(prompt::password("PGP secret key password")?) Ok(prompt::password("PGP secret key password")?)
}) })
.await?; .await?;

View file

@ -1,4 +1,3 @@
#[cfg(feature = "wizard")]
use pimalaya_tui::himalaya::config::HimalayaTomlConfig; use pimalaya_tui::himalaya::config::HimalayaTomlConfig;
pub type TomlConfig = HimalayaTomlConfig; pub type TomlConfig = HimalayaTomlConfig;

View file

@ -45,9 +45,11 @@ impl TemplateSaveCommand {
.clone() .clone()
.into_account_configs(self.account.name.as_deref())?; .into_account_configs(self.account.name.as_deref())?;
let account_config = Arc::new(account_config);
let backend = BackendBuilder::new( let backend = BackendBuilder::new(
Arc::new(toml_account_config), Arc::new(toml_account_config),
Arc::new(account_config), account_config.clone(),
|builder| { |builder| {
builder builder
.without_features() .without_features()

View file

@ -39,9 +39,11 @@ impl TemplateSendCommand {
.clone() .clone()
.into_account_configs(self.account.name.as_deref())?; .into_account_configs(self.account.name.as_deref())?;
let account_config = Arc::new(account_config);
let backend = BackendBuilder::new( let backend = BackendBuilder::new(
Arc::new(toml_account_config), Arc::new(toml_account_config),
Arc::new(account_config), account_config.clone(),
|builder| { |builder| {
builder builder
.without_features() .without_features()