Skip to content

Commit 31c403a

Browse files
committed
HACK: Ignore casing on more tables
1 parent 7c3f81a commit 31c403a

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
@@ -485,7 +485,7 @@ async fn migrate_threepids(
485485
.into_extract_localpart(synapse_user_id.clone())?
486486
.to_owned();
487487
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
488-
// HACK(matrix.org): we seem to have many threepids for unknown users
488+
// HACK(matrix.org): we seem to have casing inconsistencies
489489
if state.users.contains_key(username.to_lowercase().as_str()) {
490490
tracing::warn!(mxid = %synapse_user_id, "Threepid found in the database matching an MXID with the wrong casing");
491491
continue;
@@ -583,6 +583,12 @@ async fn migrate_external_ids(
583583
.into_extract_localpart(synapse_user_id.clone())?
584584
.to_owned();
585585
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
586+
// HACK(matrix.org): we seem to have casing inconsistencies
587+
if state.users.contains_key(username.to_lowercase().as_str()) {
588+
tracing::warn!(mxid = %synapse_user_id, "External ID found in the database matching an MXID with the wrong casing");
589+
continue;
590+
}
591+
586592
return Err(Error::MissingUserFromDependentTable {
587593
table: "user_external_ids".to_owned(),
588594
user: synapse_user_id,
@@ -680,6 +686,12 @@ async fn migrate_devices(
680686
.into_extract_localpart(synapse_user_id.clone())?
681687
.to_owned();
682688
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
689+
// HACK(matrix.org): we seem to have casing inconsistencies
690+
if state.users.contains_key(username.to_lowercase().as_str()) {
691+
tracing::warn!(mxid = %synapse_user_id, "Device found in the database matching an MXID with the wrong casing");
692+
continue;
693+
}
694+
683695
return Err(Error::MissingUserFromDependentTable {
684696
table: "devices".to_owned(),
685697
user: synapse_user_id,
@@ -822,6 +834,12 @@ async fn migrate_unrefreshable_access_tokens(
822834
.into_extract_localpart(synapse_user_id.clone())?
823835
.to_owned();
824836
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
837+
// HACK(matrix.org): we seem to have casing inconsistencies
838+
if state.users.contains_key(username.to_lowercase().as_str()) {
839+
tracing::warn!(mxid = %synapse_user_id, "Access token found in the database matching an MXID with the wrong casing");
840+
continue;
841+
}
842+
825843
return Err(Error::MissingUserFromDependentTable {
826844
table: "access_tokens".to_owned(),
827845
user: synapse_user_id,
@@ -970,6 +988,12 @@ async fn migrate_refreshable_token_pairs(
970988
.into_extract_localpart(synapse_user_id.clone())?
971989
.to_owned();
972990
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
991+
// HACK(matrix.org): we seem to have casing inconsistencies
992+
if state.users.contains_key(username.to_lowercase().as_str()) {
993+
tracing::warn!(mxid = %synapse_user_id, "Refresh token found in the database matching an MXID with the wrong casing");
994+
continue;
995+
}
996+
973997
return Err(Error::MissingUserFromDependentTable {
974998
table: "refresh_tokens".to_owned(),
975999
user: synapse_user_id,

0 commit comments

Comments
 (0)