Do not emit network errors during configuration

Previously DC_EVENT_ERROR_NETWORK events were emitted for each failed
attempt during autoconfiguration, even if eventually configuration
succeeded. Such error reports are not useful and often confusing,
especially if they report failures to connect to domains that don't
exist, such as imap.example.org when mail.example.org should be used.

Now DC_EVENT_ERROR_NETWORK is only emitted when attempting to connect
with existing IMAP and SMTP configuration already stored in the
database.

Configuration failure is still indicated by DC_EVENT_CONFIGURE_PROGRESS
with data1 set to 0. Python tests from TestOnlineConfigurationFails
group are changed to only wait for this event.
This commit is contained in:
Alexander Krotov
2020-09-05 04:34:42 +03:00
committed by link2xt
parent 9b741825ef
commit e388e4cc1e
4 changed files with 60 additions and 38 deletions

View File

@@ -101,13 +101,26 @@ impl Smtp {
}
let lp = LoginParam::from_database(context, "configured_").await;
self.connect(
context,
&lp.smtp,
&lp.addr,
lp.server_flags & DC_LP_AUTH_OAUTH2 != 0,
)
.await
let res = self
.connect(
context,
&lp.smtp,
&lp.addr,
lp.server_flags & DC_LP_AUTH_OAUTH2 != 0,
)
.await;
if let Err(ref err) = res {
let message = context
.stock_string_repl_str2(
StockMessage::ServerResponse,
format!("SMTP {}:{}", lp.smtp.server, lp.smtp.port),
err.to_string(),
)
.await;
context.emit_event(EventType::ErrorNetwork(message));
};
res
}
/// Connect using the provided login params.
@@ -124,7 +137,6 @@ impl Smtp {
}
if lp.server.is_empty() || lp.port == 0 {
context.emit_event(EventType::ErrorNetwork("SMTP bad parameters.".into()));
return Err(Error::BadParameters);
}
@@ -197,15 +209,6 @@ impl Smtp {
let mut trans = client.into_transport();
if let Err(err) = trans.connect().await {
let message = context
.stock_string_repl_str2(
StockMessage::ServerResponse,
format!("SMTP {}:{}", domain, port),
err.to_string(),
)
.await;
emit_event!(context, EventType::ErrorNetwork(message));
return Err(Error::ConnectionFailure(err));
}