mirror of
https://github.com/chatmail/core.git
synced 2026-04-23 00:16:34 +03:00
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:
25
src/smtp.rs
25
src/smtp.rs
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user