mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Query MX records during provider autoconfiguration
Previously MX records were queried only for OAuth 2 configuration and did not affect the list of servers tried. User was required to manually configure the servers for Google Workspace (former GSuite) domains. Now MX records are queried during configuration. If provider is found in offline database, its ID, corresponding to the filename, is saved as `configured_provider`. `configured_provider` is also set during database migration if email address uses the domain from the provider database, but no MX querying is done.
This commit is contained in:
committed by
link2xt
parent
6edff503aa
commit
f4c8ffca4c
18
src/sql.rs
18
src/sql.rs
@@ -16,6 +16,7 @@ use crate::ephemeral::start_ephemeral_timers;
|
||||
use crate::error::format_err;
|
||||
use crate::param::*;
|
||||
use crate::peerstate::*;
|
||||
use crate::provider::get_provider_by_domain;
|
||||
use crate::{
|
||||
chat::{update_device_icon, update_saved_messages_icon},
|
||||
config::Config,
|
||||
@@ -1395,6 +1396,23 @@ CREATE INDEX devmsglabels_index1 ON devmsglabels (label);
|
||||
.await?;
|
||||
sql.set_raw_config_int(context, "dbversion", 69).await?;
|
||||
}
|
||||
if dbversion < 70 {
|
||||
info!(context, "[migration] v70");
|
||||
if let Some(addr) = context.get_config(Config::ConfiguredAddr).await {
|
||||
if let Ok(domain) = addr.parse::<EmailAddress>().map(|email| email.domain) {
|
||||
context
|
||||
.set_config(
|
||||
Config::ConfiguredProvider,
|
||||
get_provider_by_domain(&domain).map(|provider| provider.id),
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
warn!(context, "Can't parse configured address: {:?}", addr);
|
||||
}
|
||||
}
|
||||
|
||||
sql.set_raw_config_int(context, "dbversion", 70).await?;
|
||||
}
|
||||
|
||||
// (2) updates that require high-level objects
|
||||
// (the structure is complete now and all objects are usable)
|
||||
|
||||
Reference in New Issue
Block a user