Add extra_identities configuration flag

Closes #119

Multi identies per account #119 https://git.meli.delivery/meli/meli/issues/119
pull/144/head
Manos Pitsidianakis 2022-03-21 20:53:37 +02:00
parent aa3524dd30
commit 81184b182c
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
4 changed files with 24 additions and 0 deletions

View File

@ -138,6 +138,9 @@ The glob wildcard
can be used to match every mailbox name and path.
.It Ic identity Ar String
Your e-mail address that is inserted in the From: headers of outgoing mail.
.It Ic extra_identities Ar [String,]
Extra e-mail address identities.
When replying to an e-mail addressed to one of these identities, the From: header will be adjusted to its value instead of the default identity.
.El
.TS
allbox tab(:);

View File

@ -30,6 +30,7 @@ pub struct AccountSettings {
pub root_mailbox: String,
pub format: String,
pub identity: String,
pub extra_identities: Vec<String>,
pub read_only: bool,
pub display_name: Option<String>,
pub subscribed_mailboxes: Vec<String>,

View File

@ -249,6 +249,21 @@ impl Composer {
ret.draft
.set_header("In-Reply-To", envelope.message_id_display().into());
if let Some(reply_to) = envelope
.other_headers()
.get("To")
.and_then(|v| v.as_str().try_into().ok())
{
let to: &str = reply_to;
let extra_identities = &account.settings.account.extra_identities;
if let Some(extra) = extra_identities
.iter()
.find(|extra| to.contains(extra.as_str()))
{
ret.draft.set_header("From", extra.into());
}
}
// "Mail-Followup-To/(To+Cc+(Mail-Reply-To/Reply-To/From)) for follow-up,
// Mail-Reply-To/Reply-To/From for reply-to-author."
// source: https://cr.yp.to/proto/replyto.html

View File

@ -155,6 +155,8 @@ pub struct FileAccount {
root_mailbox: String,
format: String,
identity: String,
#[serde(default)]
extra_identities: Vec<String>,
#[serde(default = "none")]
display_name: Option<String>,
@ -254,6 +256,7 @@ impl From<FileAccount> for AccountConf {
root_mailbox,
format,
identity,
extra_identities: x.extra_identities.clone(),
read_only: x.read_only,
display_name,
subscribed_mailboxes: x.subscribed_mailboxes.clone(),
@ -444,6 +447,7 @@ This is required so that you don't accidentally start meli and find out later th
root_mailbox,
format,
identity,
extra_identities,
read_only,
display_name,
subscribed_mailboxes,
@ -461,6 +465,7 @@ This is required so that you don't accidentally start meli and find out later th
root_mailbox,
format: format.clone(),
identity,
extra_identities,
read_only,
display_name,
subscribed_mailboxes,