mirror of
https://github.com/chatmail/core.git
synced 2026-05-18 22:36:29 +03:00
fix: Don't change ConfiguredAddr when adding a transport (#6804)
Before this PR, ConfiguredAddr (which will be used to store the primary transport) would have been changed when adding a new transport. Doesn't matter yet because it's not possible yet to have multiple transports. But I wanted to fix this bug already so that I'm not suprised by it later.
This commit is contained in:
@@ -809,20 +809,14 @@ impl ConfiguredLoginParam {
|
|||||||
entered_param: &EnteredLoginParam,
|
entered_param: &EnteredLoginParam,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let addr = addr_normalize(&self.addr);
|
let addr = addr_normalize(&self.addr);
|
||||||
|
let provider_id = self.provider.map(|provider| provider.id);
|
||||||
let configured_addr = context.get_config(Config::ConfiguredAddr).await?;
|
let configured_addr = context.get_config(Config::ConfiguredAddr).await?;
|
||||||
if let Some(configured_addr) = configured_addr {
|
if let Some(configured_addr) = &configured_addr {
|
||||||
ensure!(
|
ensure!(
|
||||||
addr_cmp(&configured_addr, &addr,),
|
addr_cmp(configured_addr, &addr),
|
||||||
"Adding a second transport is not supported right now."
|
"Adding a second transport is not supported right now."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
context
|
|
||||||
.sql
|
|
||||||
.set_raw_config(
|
|
||||||
Config::ConfiguredProvider.as_ref(),
|
|
||||||
self.provider.map(|provider| provider.id),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
@@ -837,10 +831,17 @@ impl ConfiguredLoginParam {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
context
|
if configured_addr.is_none() {
|
||||||
.sql
|
// If there is no transport yet, set the new transport as the primary one
|
||||||
.set_raw_config(Config::ConfiguredAddr.as_ref(), Some(&addr))
|
context
|
||||||
.await?;
|
.sql
|
||||||
|
.set_raw_config(Config::ConfiguredProvider.as_ref(), provider_id)
|
||||||
|
.await?;
|
||||||
|
context
|
||||||
|
.sql
|
||||||
|
.set_raw_config(Config::ConfiguredAddr.as_ref(), Some(&addr))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user