Skip to content

Commit 6b02497

Browse files
committed
Build the provider ID mapping
1 parent c9ae892 commit 6b02497

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

crates/cli/src/commands/syn2mas.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use clap::Parser;
66
use figment::Figment;
77
use mas_config::{
88
ConfigurationSection, ConfigurationSectionExt, DatabaseConfig, MatrixConfig, SyncConfig,
9+
UpstreamOAuth2Config,
910
};
1011
use mas_storage::SystemClock;
1112
use mas_storage_pg::MIGRATOR;
@@ -200,7 +201,19 @@ impl Options {
200201
Ok(ExitCode::SUCCESS)
201202
}
202203
Subcommand::Migrate => {
203-
let provider_id_mappings: HashMap<String, Uuid> = HashMap::new();
204+
let provider_id_mappings: HashMap<String, Uuid> = {
205+
let mas_oauth2 = UpstreamOAuth2Config::extract_or_default(figment)?;
206+
207+
mas_oauth2
208+
.providers
209+
.iter()
210+
.filter_map(|provider| {
211+
let synapse_idp_id = provider.synapse_idp_id.clone()?;
212+
Some((synapse_idp_id, Uuid::from(provider.id)))
213+
})
214+
.collect()
215+
};
216+
204217
// TODO how should we handle warnings at this stage?
205218

206219
let mut reader = SynapseReader::new(&mut syn_conn, true).await?;

0 commit comments

Comments
 (0)