mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 17:15:12 +00:00
fix features warns and save sent message copy option
This commit is contained in:
parent
a6b863759c
commit
819bdc84b3
|
@ -204,10 +204,10 @@ impl TomlAccountConfig {
|
|||
|
||||
#[cfg(feature = "message-delete")]
|
||||
pub fn delete_messages_kind(&self) -> Option<&BackendKind> {
|
||||
self.flag
|
||||
self.message
|
||||
.as_ref()
|
||||
.and_then(|flag| flag.remove.as_ref())
|
||||
.and_then(|remove| remove.backend.as_ref())
|
||||
.and_then(|message| message.delete.as_ref())
|
||||
.and_then(|delete| delete.backend.as_ref())
|
||||
.or_else(|| self.backend.as_ref())
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ use email::sendmail::SendmailContext;
|
|||
#[cfg(feature = "smtp")]
|
||||
use email::smtp::{SmtpClientBuilder, SmtpClientSync};
|
||||
|
||||
#[cfg(any(feature = "flag-command"))]
|
||||
#[allow(unused)]
|
||||
use email::{
|
||||
envelope::Id,
|
||||
flag::{Flag, Flags},
|
||||
|
|
|
@ -8,6 +8,7 @@ use log::info;
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -57,7 +58,7 @@ impl MessageCopyCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
copy_messages_kind,
|
||||
|builder| match copy_messages_kind {
|
||||
|#[allow(unused)] builder| match copy_messages_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder
|
||||
|
|
|
@ -8,6 +8,7 @@ use log::info;
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -58,7 +59,7 @@ impl MessageDeleteCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
delete_messages_kind,
|
||||
|builder| match delete_messages_kind {
|
||||
|#[allow(unused)] builder| match delete_messages_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder
|
||||
|
|
|
@ -12,6 +12,7 @@ use log::info;
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -70,7 +71,7 @@ impl MessageForwardCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
add_message_kind.into_iter().chain(send_message_kind),
|
||||
|builder| {
|
||||
|#[allow(unused)] builder| {
|
||||
match add_message_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
|
|
|
@ -8,6 +8,7 @@ use log::info;
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -57,7 +58,7 @@ impl MessageMoveCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
move_messages_kind,
|
||||
|builder| match move_messages_kind {
|
||||
|#[allow(unused)] builder| match move_messages_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder
|
||||
|
|
|
@ -9,6 +9,7 @@ use mml::message::FilterParts;
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -102,7 +103,7 @@ impl MessageReadCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
get_messages_kind,
|
||||
|builder| match get_messages_kind {
|
||||
|#[allow(unused)] builder| match get_messages_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use clap::Parser;
|
||||
use email::flag::Flag;
|
||||
#[cfg(feature = "imap")]
|
||||
use email::message::add::imap::AddMessageImap;
|
||||
#[cfg(feature = "maildir")]
|
||||
|
@ -13,6 +12,7 @@ use log::info;
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -73,7 +73,7 @@ impl MessageReplyCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
add_message_kind.into_iter().chain(send_message_kind),
|
||||
|builder| {
|
||||
|#[allow(unused)] builder| {
|
||||
match add_message_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
|
@ -130,9 +130,6 @@ impl MessageReplyCommand {
|
|||
.with_reply_all(self.reply.all)
|
||||
.build()
|
||||
.await?;
|
||||
editor::edit_tpl_with_editor(&account_config, printer, &backend, tpl).await?;
|
||||
|
||||
// TODO: let backend.send_reply_message adding the flag
|
||||
backend.add_flag(&folder, &[id], Flag::Answered).await
|
||||
editor::edit_tpl_with_editor(&account_config, printer, &backend, tpl).await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use std::io::{self, BufRead, IsTerminal};
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -55,7 +56,7 @@ impl MessageSaveCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
add_message_kind,
|
||||
|builder| match add_message_kind {
|
||||
|#[allow(unused)] builder| match add_message_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder.set_add_message(|ctx| ctx.imap.as_ref().and_then(AddMessageImap::new));
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
#[cfg(feature = "imap")]
|
||||
use email::message::add_with_flags::imap::AddMessageWithFlagsImap;
|
||||
#[cfg(feature = "maildir")]
|
||||
use email::message::add_with_flags::maildir::AddMessageWithFlagsMaildir;
|
||||
#[cfg(feature = "sendmail")]
|
||||
use email::message::send::sendmail::SendMessageSendmail;
|
||||
#[cfg(feature = "smtp")]
|
||||
|
@ -9,6 +13,7 @@ use std::io::{self, BufRead, IsTerminal};
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -46,11 +51,43 @@ impl MessageSendCommand {
|
|||
|
||||
let send_message_kind = toml_account_config.send_message_kind();
|
||||
|
||||
#[cfg(feature = "message-add")]
|
||||
let add_message_kind = toml_account_config
|
||||
.add_message_kind()
|
||||
.filter(|_| account_config.should_save_copy_sent_message());
|
||||
#[cfg(not(feature = "message-add"))]
|
||||
let add_message_kind = None;
|
||||
|
||||
let backend = Backend::new(
|
||||
&toml_account_config,
|
||||
&account_config,
|
||||
send_message_kind,
|
||||
|builder| {
|
||||
send_message_kind.into_iter().chain(add_message_kind),
|
||||
|#[allow(unused)] builder| {
|
||||
match add_message_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder.set_add_message_with_flags(|ctx| {
|
||||
ctx.imap.as_ref().and_then(AddMessageWithFlagsImap::new)
|
||||
});
|
||||
}
|
||||
#[cfg(feature = "maildir")]
|
||||
Some(BackendKind::Maildir) => {
|
||||
builder.set_add_message_with_flags(|ctx| {
|
||||
ctx.maildir
|
||||
.as_ref()
|
||||
.and_then(AddMessageWithFlagsMaildir::new)
|
||||
});
|
||||
}
|
||||
#[cfg(feature = "sync")]
|
||||
Some(BackendKind::MaildirForSync) => {
|
||||
builder.set_add_message_with_flags(|ctx| {
|
||||
ctx.maildir_for_sync
|
||||
.as_ref()
|
||||
.and_then(AddMessageWithFlagsMaildir::new)
|
||||
});
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
match send_message_kind {
|
||||
#[cfg(feature = "smtp")]
|
||||
Some(BackendKind::Smtp) => {
|
||||
|
|
|
@ -13,6 +13,7 @@ use log::info;
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -61,7 +62,7 @@ impl MessageWriteCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
add_message_kind.into_iter().chain(send_message_kind),
|
||||
|builder| {
|
||||
|#[allow(unused)] builder| {
|
||||
match add_message_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
|
|
|
@ -18,6 +18,8 @@ pub struct MessageConfig {
|
|||
#[cfg(feature = "message-move")]
|
||||
#[serde(rename = "move")]
|
||||
pub move_: Option<MessageMoveConfig>,
|
||||
#[cfg(feature = "message-delete")]
|
||||
pub delete: Option<MessageDeleteConfig>,
|
||||
}
|
||||
|
||||
impl MessageConfig {
|
||||
|
@ -181,3 +183,22 @@ impl MessageMoveConfig {
|
|||
kinds
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "message-delete")]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
|
||||
pub struct MessageDeleteConfig {
|
||||
pub backend: Option<BackendKind>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "message-delete")]
|
||||
impl MessageDeleteConfig {
|
||||
pub fn get_used_backends(&self) -> HashSet<&BackendKind> {
|
||||
let mut kinds = HashSet::default();
|
||||
|
||||
if let Some(kind) = &self.backend {
|
||||
kinds.insert(kind);
|
||||
}
|
||||
|
||||
kinds
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use log::info;
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -63,7 +64,7 @@ impl TemplateForwardCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
get_messages_kind,
|
||||
|builder| match get_messages_kind {
|
||||
|#[allow(unused)] builder| match get_messages_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder
|
||||
|
|
|
@ -8,6 +8,7 @@ use log::info;
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -68,7 +69,7 @@ impl TemplateReplyCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
get_messages_kind,
|
||||
|builder| match get_messages_kind {
|
||||
|#[allow(unused)] builder| match get_messages_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder
|
||||
|
|
|
@ -10,6 +10,7 @@ use std::io::{self, BufRead, IsTerminal};
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -59,7 +60,7 @@ impl TemplateSaveCommand {
|
|||
&toml_account_config,
|
||||
&account_config,
|
||||
add_message_kind,
|
||||
|builder| match add_message_kind {
|
||||
|#[allow(unused)] builder| match add_message_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder.set_add_message(|ctx| ctx.imap.as_ref().and_then(AddMessageImap::new));
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
#[cfg(feature = "imap")]
|
||||
use email::message::add_with_flags::imap::AddMessageWithFlagsImap;
|
||||
#[cfg(feature = "maildir")]
|
||||
use email::message::add_with_flags::maildir::AddMessageWithFlagsMaildir;
|
||||
#[cfg(feature = "sendmail")]
|
||||
use email::message::send::sendmail::SendMessageSendmail;
|
||||
#[cfg(feature = "smtp")]
|
||||
|
@ -10,6 +14,7 @@ use std::io::{self, BufRead, IsTerminal};
|
|||
|
||||
#[cfg(feature = "sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
#[allow(unused)]
|
||||
use crate::{
|
||||
account::arg::name::AccountNameFlag,
|
||||
backend::{Backend, BackendKind},
|
||||
|
@ -49,11 +54,43 @@ impl TemplateSendCommand {
|
|||
|
||||
let send_message_kind = toml_account_config.send_message_kind();
|
||||
|
||||
#[cfg(feature = "message-add")]
|
||||
let add_message_kind = toml_account_config
|
||||
.add_message_kind()
|
||||
.filter(|_| account_config.should_save_copy_sent_message());
|
||||
#[cfg(not(feature = "message-add"))]
|
||||
let add_message_kind = None;
|
||||
|
||||
let backend = Backend::new(
|
||||
&toml_account_config,
|
||||
&account_config,
|
||||
send_message_kind,
|
||||
|builder| {
|
||||
send_message_kind.into_iter().chain(add_message_kind),
|
||||
|#[allow(unused)] builder| {
|
||||
match add_message_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder.set_add_message_with_flags(|ctx| {
|
||||
ctx.imap.as_ref().and_then(AddMessageWithFlagsImap::new)
|
||||
});
|
||||
}
|
||||
#[cfg(feature = "maildir")]
|
||||
Some(BackendKind::Maildir) => {
|
||||
builder.set_add_message_with_flags(|ctx| {
|
||||
ctx.maildir
|
||||
.as_ref()
|
||||
.and_then(AddMessageWithFlagsMaildir::new)
|
||||
});
|
||||
}
|
||||
#[cfg(feature = "sync")]
|
||||
Some(BackendKind::MaildirForSync) => {
|
||||
builder.set_add_message_with_flags(|ctx| {
|
||||
ctx.maildir_for_sync
|
||||
.as_ref()
|
||||
.and_then(AddMessageWithFlagsMaildir::new)
|
||||
});
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
match send_message_kind {
|
||||
#[cfg(feature = "smtp")]
|
||||
Some(BackendKind::Smtp) => {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#[cfg(feature = "folder-command")]
|
||||
pub mod arg;
|
||||
#[cfg(feature = "folder-command")]
|
||||
pub mod command;
|
||||
|
|
Loading…
Reference in a new issue