Connectivity view: Only set smtp to "connected" if the last message was actually sent (#2541)

fix #2539

It's always a bit ambiguous which function should do set_err or set last_send_error, I used this rule here:

If some code returns Status::RetryLater, then it sets last_send_error, because Status::RetryLater means that the user won't see the error directly on the message (if we returned Status::Failed(Err(_)), then the message would be shown as failed to the user) Also, smtp_send always sets last_send_error because, well, sending just failed or succeeded.

Also, remove unused field pending_error.
This commit is contained in:
Hocuri
2021-08-09 12:31:33 +02:00
committed by GitHub
parent 20bf41b4e6
commit faab61b0d4
3 changed files with 24 additions and 21 deletions

View File

@@ -54,6 +54,9 @@ pub(crate) struct Smtp {
last_success: Option<SystemTime>,
pub(crate) connectivity: ConnectivityStore,
/// If sending the last message failed, contains the error message.
pub(crate) last_send_error: Option<String>,
}
impl Smtp {
@@ -100,20 +103,14 @@ impl Smtp {
self.connectivity.set_connecting(context).await;
let lp = LoginParam::from_database(context, "configured_").await?;
let res = self
.connect(
context,
&lp.smtp,
&lp.addr,
lp.server_flags & DC_LP_AUTH_OAUTH2 != 0,
lp.provider.map_or(false, |provider| provider.strict_tls),
)
.await;
if let Err(err) = &res {
self.connectivity.set_err(context, err).await;
}
res
self.connect(
context,
&lp.smtp,
&lp.addr,
lp.server_flags & DC_LP_AUTH_OAUTH2 != 0,
lp.provider.map_or(false, |provider| provider.strict_tls),
)
.await
}
/// Connect using the provided login params.