configure: always try at least one IMAP and SMTP server

Previously empty autoconfig resulted in no servers being tried and no
error displayed.
This commit is contained in:
Alexander Krotov
2020-10-21 02:12:47 +03:00
committed by link2xt
parent 5a9a4dbbab
commit 8156692e5a

View File

@@ -217,28 +217,32 @@ async fn configure(ctx: &Context, param: &mut LoginParam) -> Result<()> {
progress!(ctx, 500); progress!(ctx, 500);
let servers = expand_param_vector( let mut servers = param_autoconfig.unwrap_or_default();
param_autoconfig.unwrap_or_else(|| { if !servers
vec![ .iter()
ServerParams { .any(|server| server.protocol == Protocol::IMAP)
protocol: Protocol::IMAP, {
hostname: param.imap.server.clone(), servers.push(ServerParams {
port: param.imap.port, protocol: Protocol::IMAP,
socket: param.imap.security, hostname: param.imap.server.clone(),
username: param.imap.user.clone(), port: param.imap.port,
}, socket: param.imap.security,
ServerParams { username: param.imap.user.clone(),
protocol: Protocol::SMTP, })
hostname: param.smtp.server.clone(), }
port: param.smtp.port, if !servers
socket: param.smtp.security, .iter()
username: param.smtp.user.clone(), .any(|server| server.protocol == Protocol::SMTP)
}, {
] servers.push(ServerParams {
}), protocol: Protocol::SMTP,
&param.addr, hostname: param.smtp.server.clone(),
&param_domain, port: param.smtp.port,
); socket: param.smtp.security,
username: param.smtp.user.clone(),
})
}
let servers = expand_param_vector(servers, &param.addr, &param_domain);
progress!(ctx, 550); progress!(ctx, 550);
@@ -560,7 +564,9 @@ async fn nicer_configuration_error(context: &Context, errors: Vec<ConfigurationE
let first_err = if let Some(f) = errors.first() { let first_err = if let Some(f) = errors.first() {
f f
} else { } else {
return "".to_string(); // This means configuration failed but no errors have been captured. This should never
// happen, but if it does, the user will see classic "Error: no error".
return "no error".to_string();
}; };
if errors if errors