Skip to content

Commit 8eb4703

Browse files
committed
HACK: Ignore casing on more tables
1 parent ea8876a commit 8eb4703

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

crates/syn2mas/src/migration.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ async fn migrate_threepids(
370370
.into_extract_localpart(synapse_user_id.clone())?
371371
.to_owned();
372372
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
373-
// HACK(matrix.org): we seem to have many threepids for unknown users
373+
// HACK(matrix.org): we seem to have casing inconsistencies
374374
if state.users.contains_key(username.to_lowercase().as_str()) {
375375
tracing::warn!(mxid = %synapse_user_id, "Threepid found in the database matching an MXID with the wrong casing");
376376
continue;
@@ -467,6 +467,12 @@ async fn migrate_external_ids(
467467
.into_extract_localpart(synapse_user_id.clone())?
468468
.to_owned();
469469
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
470+
// HACK(matrix.org): we seem to have casing inconsistencies
471+
if state.users.contains_key(username.to_lowercase().as_str()) {
472+
tracing::warn!(mxid = %synapse_user_id, "External ID found in the database matching an MXID with the wrong casing");
473+
continue;
474+
}
475+
470476
return Err(Error::MissingUserFromDependentTable {
471477
table: "user_external_ids".to_owned(),
472478
user: synapse_user_id,
@@ -558,6 +564,12 @@ async fn migrate_devices(
558564
.into_extract_localpart(synapse_user_id.clone())?
559565
.to_owned();
560566
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
567+
// HACK(matrix.org): we seem to have casing inconsistencies
568+
if state.users.contains_key(username.to_lowercase().as_str()) {
569+
tracing::warn!(mxid = %synapse_user_id, "Device found in the database matching an MXID with the wrong casing");
570+
continue;
571+
}
572+
561573
return Err(Error::MissingUserFromDependentTable {
562574
table: "devices".to_owned(),
563575
user: synapse_user_id,
@@ -687,6 +699,12 @@ async fn migrate_unrefreshable_access_tokens(
687699
.into_extract_localpart(synapse_user_id.clone())?
688700
.to_owned();
689701
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
702+
// HACK(matrix.org): we seem to have casing inconsistencies
703+
if state.users.contains_key(username.to_lowercase().as_str()) {
704+
tracing::warn!(mxid = %synapse_user_id, "Access token found in the database matching an MXID with the wrong casing");
705+
continue;
706+
}
707+
690708
return Err(Error::MissingUserFromDependentTable {
691709
table: "access_tokens".to_owned(),
692710
user: synapse_user_id,
@@ -832,6 +850,12 @@ async fn migrate_refreshable_token_pairs(
832850
.into_extract_localpart(synapse_user_id.clone())?
833851
.to_owned();
834852
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
853+
// HACK(matrix.org): we seem to have casing inconsistencies
854+
if state.users.contains_key(username.to_lowercase().as_str()) {
855+
tracing::warn!(mxid = %synapse_user_id, "Refresh token found in the database matching an MXID with the wrong casing");
856+
continue;
857+
}
858+
835859
return Err(Error::MissingUserFromDependentTable {
836860
table: "refresh_tokens".to_owned(),
837861
user: synapse_user_id,

0 commit comments

Comments
 (0)