compose: add extra_submission_headers fields in composer form and autocomplete for Newsgroups
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (pull_request) Successful in 10m32s Details
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (push) Successful in 10m14s Details

Submitting to NNTP/Usenet servers requires you to specify which news
groups the post/article is going to. This commit places all
extra_submission_headers from a backend (in this case only NNTP
implements this) in the composing form fields.

Fixes #267

nntp should add Newsgroups header if missing
<https://git.meli.delivery/meli/meli/issues/267>

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/305/head
Manos Pitsidianakis 2023-09-23 18:49:51 +03:00
parent e88957ae6e
commit d3cbf184e6
Signed by: Manos Pitsidianakis
GPG Key ID: 7729C7707F7E09D0
1 changed files with 36 additions and 1 deletions

View File

@ -207,6 +207,14 @@ impl Composer {
.iter()
.any(|hn| hn.as_str() == h.name())
});
for h in context.accounts[&account_hash]
.backend_capabilities
.extra_submission_headers
{
ret.draft.set_header(h.clone(), String::new());
}
for (h, v) in
account_settings!(context[account_hash].composing.default_header_values).iter()
{
@ -582,6 +590,33 @@ To: {}
self.form.set_cursor(old_cursor);
let headers = self.draft.headers();
let account_hash = self.account_hash;
for k in context.accounts[&account_hash]
.backend_capabilities
.extra_submission_headers
{
if matches!(*k, HeaderName::NEWSGROUPS) {
self.form.push_cl((
k.into(),
headers[k].to_string(),
Box::new(move |c, term| {
c.accounts[&account_hash]
.mailbox_entries
.values()
.filter_map(|v| {
if v.path.starts_with(term) {
Some(v.path.to_string())
} else {
None
}
})
.map(AutoCompleteEntry::from)
.collect::<Vec<AutoCompleteEntry>>()
}),
));
} else {
self.form.push((k.into(), headers[k].to_string()));
}
}
for k in &[
HeaderName::DATE,
HeaderName::FROM,
@ -590,7 +625,7 @@ To: {}
HeaderName::BCC,
HeaderName::SUBJECT,
] {
if k == HeaderName::TO || k == HeaderName::CC || k == HeaderName::BCC {
if matches!(*k, HeaderName::TO | HeaderName::CC | HeaderName::BCC) {
self.form.push_cl((
k.into(),
headers[k].to_string(),