mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 21:36:29 +03:00
Validate and simplify LoginParam struct
This makes sure that under normal circumstances the LoginParam struct is always fully validated, ensure future use does not have to be careful with this. The brittle handling of `server_flags` is also abstraced away from users of it and is now handled entirely internally, as the flags is really only a boolean a lot of the flag parsing complexity is removed. The OAuth2 flag is moved into the ServerLoginParam struct as it really belongs in there.
This commit is contained in:
@@ -11,7 +11,6 @@ use async_smtp::{smtp, EmailAddress, ServerAddress};
|
||||
use async_std::task;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::constants::DC_LP_AUTH_OAUTH2;
|
||||
use crate::contact::{Contact, ContactId};
|
||||
use crate::events::EventType;
|
||||
use crate::login_param::{
|
||||
@@ -103,7 +102,6 @@ impl Smtp {
|
||||
&lp.smtp,
|
||||
&lp.socks5_config,
|
||||
&lp.addr,
|
||||
lp.server_flags & DC_LP_AUTH_OAUTH2 != 0,
|
||||
lp.provider
|
||||
.map_or(lp.socks5_config.is_some(), |provider| provider.strict_tls),
|
||||
)
|
||||
@@ -117,7 +115,6 @@ impl Smtp {
|
||||
lp: &ServerLoginParam,
|
||||
socks5_config: &Option<Socks5Config>,
|
||||
addr: &str,
|
||||
oauth2: bool,
|
||||
provider_strict_tls: bool,
|
||||
) -> Result<()> {
|
||||
if self.is_connected().await {
|
||||
@@ -146,7 +143,7 @@ impl Smtp {
|
||||
let tls_config = dc_build_tls(strict_tls);
|
||||
let tls_parameters = ClientTlsParameters::new(domain.to_string(), tls_config);
|
||||
|
||||
let (creds, mechanism) = if oauth2 {
|
||||
let (creds, mechanism) = if lp.oauth2 {
|
||||
// oauth2
|
||||
let send_pw = &lp.password;
|
||||
let access_token = dc_get_oauth2_access_token(context, addr, send_pw, false).await?;
|
||||
|
||||
Reference in New Issue
Block a user