8000 Add reusable templates, quick inserts, and signature sender names by FLASH911 · Pull Request #610 · hyprlab/hylki · GitHub
[go: up one dir, main page]

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docs/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ with this signature** marks the one new messages, replies and forwards open
with; with it off for all of them, a message opens without one. A signature
left empty is not saved.

With more than one, the composer's **Insert Signature** button lists them
With more than one, the composer's **Choose Signature** button lists them
by name, with **No Signature** at the end. The one picked replaces the
signature in the message, in the same place; with none in the message, it
goes where a signature goes. Changing **From** to another account puts in
Expand Down Expand Up @@ -1198,6 +1198,10 @@ templates there, Thunderbird among them, sees the same ones.
Message** (on its right-click menu when the sidebar is folded to icons),
or <kbd>Ctrl+Shift+N</kbd>, lists every account's templates to start
from.
- **Insert Template**, in the composer's formatting row, puts a template
into the message already being written. It keeps the recipients,
conversation headers and quoted original, so a standard answer can be
inserted into a reply instead of starting a separate message.

A folder called Templates is taken for the role, at the top of the account
or directly under the Inbox. Nothing on a server marks one otherwise, so a
Expand Down Expand Up @@ -1308,7 +1312,10 @@ the next field.

### The From address

The From row lists each account's address and the aliases set up for it.
The From row lists each account's address and the send-as identities set up
for it. Several identities may use the same address with different display
names, such as a manager and a director writing from one shared mailbox;
they must use the same SMTP transport.
Its pencil turns the row into text, where any name and address can be typed
for this one message, a throwaway address or a `+tag` one, without making
it an alias; the arrow beside it goes back to the list. The message still
Expand All @@ -1322,7 +1329,7 @@ A JMAP account lists the identities the server keeps for it as well, so an
alias made in the webmail is in the From row without setting it up again.
The message is sent as the identity with its address, or as a catch-all
identity for its domain (`*@example.org`) when there is one. The account's
page in Settings shows them under Send-as aliases, read-only: they are
page in Settings shows them under Send-as identities, read-only: they are
changed where the server keeps them.

### Return and Shift+Return
Expand Down
71 changes: 71 additions & 0 deletions po/hylki.pot
Original file line number Diff line number Diff line change
Expand Up @@ -7918,3 +7918,74 @@ msgstr ""

msgid "Hyprlab"
msgstr ""

#: src/ui/accounts/pages/form.rs
msgid "Send-as identities"
msgstr ""

#: src/ui/accounts/pages/form.rs
msgid ""
"Extra names and addresses this account can send as. The same address may "
"have several names."
msgstr ""

#: src/ui/accounts/aliases.rs
msgid ""
8 "This address already has a send-as identity with its own SMTP server. "
"Several names may share an address only when they use this account's SMTP "
"server."
msgstr ""

#: src/ui/compose/setup.rs
msgid "Choose Signature"
msgstr ""

#: src/ui/compose/setup.rs
msgid "Insert Template"
msgstr ""

#: src/ui/accounts/pages/form.rs
msgid "Sender name"
msgstr ""

#: src/ui/accounts/pages/form.rs
msgid ""
"The name shown in From when this signature is selected. Leave it empty to "
"keep the account's name."
msgstr ""

#: src/ui/preferences/pages/composing.rs
msgid "Quick Inserts"
msgstr ""

#: src/ui/preferences/pages/composing.rs
msgid "Short phrases the composer can insert at the caret."
msgstr ""

#: src/ui/preferences/pages/composing.rs
msgid "Add Phrase"
msgstr ""

#: src/ui/preferences/pages/composing.rs
msgid "Phrase"
msgstr ""

#: src/ui/preferences/pages/composing.rs
msgid "Remove Phrase"
msgstr ""

#: src/ui/compose/quick_inserts.rs
msgid "No Quick Inserts"
msgstr ""

#: src/ui/compose/quick_inserts.rs
msgid "Configure Quick Inserts…"
msgstr ""

#: src/app/drafts.rs
msgid "The template goes into this message above the quoted original."
msgstr ""

#: src/app/drafts.rs
msgid "Could not load the template body."
msgstr ""
78 changes: 78 additions & 0 deletions po/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -10598,3 +10598,81 @@ msgstr "Hyprlab"

#~ msgid "Inside All Inboxes"
#~ msgstr "Внутри «Все входящие»"

#: src/ui/accounts/pages/form.rs
msgid "Send-as identities"
msgstr "Идентичности отправителя"

#: src/ui/accounts/pages/form.rs
msgid ""
"Extra names and addresses this account can send as. The same address may "
"have several names."
msgstr ""
"Дополнительные имена и адреса, от которых можно отправлять с этой учётной "
"записи. У одного адреса может быть несколько имён."

#: src/ui/accounts/aliases.rs
msgid ""
"This address already has a send-as identity with its own SMTP server. "
"Several names may share an address only when they use this account's SMTP "
"server."
msgstr ""
"У этого адреса уже есть идентичность отправителя с собственным "
"SMTP-сервером. Несколько имён могут использовать один адрес, только если "
"они отправляют через SMTP этой учётной записи."

#: src/ui/compose/setup.rs
msgid "Choose Signature"
msgstr "Выбрать подпись"

#: src/ui/compose/setup.rs
msgid "Insert Template"
msgstr "Вставить шаблон"

#: src/ui/accounts/pages/form.rs
msgid "Sender name"
msgstr "Имя отправителя"

#: src/ui/accounts/pages/form.rs
msgid ""
"The name shown in From when this signature is selected. Leave it empty to "
"keep the account's name."
msgstr ""
"Имя, отображаемое в поле «От» при выборе этой подписи. Оставьте поле "
"пустым, чтобы сохранить имя учётной записи."

#: src/ui/preferences/pages/composing.rs
msgid "Quick Inserts"
msgstr "Быстрые вставки"

#: src/ui/preferences/pages/composing.rs
msgid "Short phrases the composer can insert at the caret."
msgstr "Короткие фразы, которые можно вставлять в текст письма по месту курсора."

#: src/ui/preferences/pages/composing.rs
msgid "Add Phrase"
msgstr "Добавить фразу"

#: src/ui/preferences/pages/composing.rs
msgid "Phrase"
msgstr "Фраза"

#: src/ui/preferences/pages/composing.rs
msgid "Remove Phrase"
msgstr "Удалить фразу"

#: src/ui/compose/quick_inserts.rs
msgid "No Quick Inserts"
msgstr "Нет быстрых вставок"

#: src/ui/compose/quick_inserts.rs
msgid "Configure Quick Inserts…"
msgstr "Настроить быстрые вставки…"

#: src/app/drafts.rs
msgid "The template goes into this message above the quoted original."
msgstr "Шаблон будет вставлен в это сообщение перед цитируемым письмом."

#: src/app/drafts.rs
msgid "Could not load the template body."
msgstr "Не удалось загрузить текст шаблона."
1 change: 1 addition & 0 deletions src/app/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ mod tests {
new.set_signatures(
vec![crate::config::NamedSignature {
name: "Short".into(),
sender_name: String::new(),
html: "Jason".into(),
}],
None,
Expand Down
87 changes: 81 additions & 6 deletions src/app/compose_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,25 @@ fn account_identities(
let signature = default
.map(|i| signatures[i].html.clone())
.unwrap_or_default();
let signature_sender = default.and_then(|i| {
signatures
.get(i)
.map(|sig| sig.sender_from(&label))
.filter(|name| name != &label)
});
let pgp_key = cfg.and_then(|c| c.pgp_key.clone());
let sign_default = cfg.is_some_and(|c| c.sign_by_default);
let mut identities = vec![ComposeAccount {
id,
label,
label: signature_sender.clone().unwrap_or_else(|| label.clone()),
base_label: label.clone(),
signature: signature.clone(),
signatures: signatures.clone(),
email: email.to_string(),
pgp_key: pgp_key.clone(),
sign_default,
alias_from: None,
alias_from: signature_sender,
base_alias_from: None,
}];
for alias in cfg.map(|c| c.aliases.as_slice()).unwrap_or_default() {
let (name, addr) = split_identity(&alias.identity);
Expand All @@ -99,15 +107,21 @@ fn account_identities(
} else {
format!("{name} <{addr}>")
};
let with_sender = default
.and_then(|i| signatures.get(i))
.map(|sig| sig.sender_from(&display))
.unwrap_or_else(|| display.clone());
identities.push(ComposeAccount {
id,
label: display.clone(),
label: with_sender.clone(),
base_label: display.clone(),
signature: signature.clone(),
signatures: signatures.clone(),
email: addr,
pgp_key: pgp_key.clone(),
sign_default,
alias_from: Some(display),
alias_from: Some(with_sender),
base_alias_from: Some(display),
});
}
// A JMAP server's own identities (#346), unless the account
Expand All @@ -130,15 +144,21 @@ fn account_identities(
} else {
format!("{name} <{addr}>")
};
let with_sender = default
.and_then(|i| signatures.get(i))
.map(|sig| sig.sender_from(&display))
.unwrap_or_else(|| display.clone());
identities.push(ComposeAccount {
id,
label: display.clone(),
label: with_sender.clone(),
base_label: display.clone(),
signature: signature.clone(),
signatures: signatures.clone(),
email: addr.clone(),
pgp_key: pgp_key.clone(),
sign_default,
alias_from: Some(display),
alias_from: Some(with_sender),
base_alias_from: Some(display),
});
}
identities
Expand Down Expand Up @@ -295,6 +315,7 @@ impl AppModel {
decorations: true,
format,
signature_position: self.signature_position,
quick_inserts: self.quick_inserts.clone(),
};
(id, init)
}
Expand All @@ -317,6 +338,8 @@ impl AppModel {
}
ComposeOutput::SaveDraft(msg) => AppMsg::SaveDraftMessage(msg),
ComposeOutput::SaveTemplate(msg) => AppMsg::SaveTemplateMessage(msg),
ComposeOutput::PickTemplate { id } => AppMsg::PickTemplate { id },
ComposeOutput::OpenQuickInsertSettings => AppMsg::OpenQuickInsertSettings,
ComposeOutput::AutoSave { id, message } => AppMsg::AutoSaveDraft { id, message },
ComposeOutput::DiscardAutosave { id, origin } => {
AppMsg::DiscardAutosave { id, origin }
Expand Down Expand Up @@ -446,6 +469,58 @@ mod tests {
);
}

#[test]
fn one_address_can_have_several_send_as_names() {
let mut config = demo_account_configs();
config.truncate(1);
config[0].email = "office@example.com".into();
config[0].name = "Office".into();
config[0].aliases = vec![
toml::from_str("identity = \"Boss <office@example.com>\"").unwrap(),
toml::from_str("identity = \"Manager <office@example.com>\"").unwrap(),
];

let ids = compose_identities(&[], &config, &HashMap::new());
let rows: Vec<(&str, &str)> = ids
.iter()
.map(|c| (c.label.as_str(), c.email.as_str()))
.collect();
assert_eq!(
rows,
[
("Office <office@example.com>", "office@example.com"),
("Boss <office@example.com>", "office@example.com"),
("Manager <office@example.com>", "office@example.com"),
]
);
}

#[test]
fn the_default_signature_can_name_the_sender() {
let mut config = demo_account_configs();
config.truncate(1);
config[0].email = "office@example.com".into();
config[0].name = "Office".into();
config[0].set_signatures(
vec![crate::config::NamedSignature {
name: "Director".into(),
sender_name: "Alex Morgan".into(),
html: "Alex Morgan".into(),
}],
Some(0),
);

let ids = compose_identities(&[], &config, &HashMap::new());
assert_eq!(ids.len(), 1);
assert_eq!(ids[0].label, "Alex Morgan <office@example.com>");
assert_eq!(
ids[0].alias_from.as_deref(),
Some("Alex Morgan <office@example.com>")
);
assert_eq!(ids[0].base_label, "Office <office@example.com>");
assert_eq!(ids[0].base_alias_from, None);
}

/// B5 in the map: the reply identity is found by substring, so mail to
/// the alias ba@x.com is answered from the account a@x.com, which comes
/// first and is contained in it.
Expand Down
Loading
0