Skip to content

Commit ae9ae7e

Browse files
committed
HACK: Ignore casing on more tables
1 parent 6285b9f commit ae9ae7e

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
@@ -483,7 +483,7 @@ async fn migrate_threepids(
483483
.into_extract_localpart(synapse_user_id.clone())?
484484
.to_owned();
485485
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
486-
// HACK(matrix.org): we seem to have many threepids for unknown users
486+
// HACK(matrix.org): we seem to have casing inconsistencies
487487
if state.users.contains_key(username.to_lowercase().as_str()) {
488488
tracing::warn!(mxid = %synapse_user_id, "Threepid found in the database matching an MXID with the wrong casing");
489489
continue;
@@ -581,6 +581,12 @@ async fn migrate_external_ids(
581581
.into_extract_localpart(synapse_user_id.clone())?
582582
.to_owned();
583583
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
584+
// HACK(matrix.org): we seem to have casing inconsistencies
585+
if state.users.contains_key(username.to_lowercase().as_str()) {
586+
tracing::warn!(mxid = %synapse_user_id, "External ID found in the database matching an MXID with the wrong casing");
587+
continue;
588+
}
589+
584590
return Err(Error::MissingUserFromDependentTable {
585591
table: "user_external_ids".to_owned(),
586592
user: synapse_user_id,
@@ -676,6 +682,12 @@ async fn migrate_devices(
676682
.into_extract_localpart(synapse_user_id.clone())?
677683
.to_owned();
678684
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
685+
// HACK(matrix.org): we seem to have casing inconsistencies
686+
if state.users.contains_key(username.to_lowercase().as_str()) {
687+
tracing::warn!(mxid = %synapse_user_id, "Device found in the database matching an MXID with the wrong casing");
688+
continue;
689+
}
690+
679691
return Err(Error::MissingUserFromDependentTable {
680692
table: "devices".to_owned(),
681693
user: synapse_user_id,
@@ -816,6 +828,12 @@ async fn migrate_unrefreshable_access_tokens(
816828
.into_extract_localpart(synapse_user_id.clone())?
817829
.to_owned();
818830
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
831+
// HACK(matrix.org): we seem to have casing inconsistencies
832+
if state.users.contains_key(username.to_lowercase().as_str()) {
833+
tracing::warn!(mxid = %synapse_user_id, "Access token found in the database matching an MXID with the wrong casing");
834+
continue;
835+
}
836+
819837
return Err(Error::MissingUserFromDependentTable {
820838
table: "access_tokens".to_owned(),
821839
user: synapse_user_id,
@@ -964,6 +982,12 @@ async fn migrate_refreshable_token_pairs(
964982
.into_extract_localpart(synapse_user_id.clone())?
965983
.to_owned();
966984
let Some(user_infos) = state.users.get(username.as_str()).copied() else {
985+
// HACK(matrix.org): we seem to have casing inconsistencies
986+
if state.users.contains_key(username.to_lowercase().as_str()) {
987+
tracing::warn!(mxid = %synapse_user_id, "Refresh token found in the database matching an MXID with the wrong casing");
988+
continue;
989+
}
990+
967991
return Err(Error::MissingUserFromDependentTable {
968992
table: "refresh_tokens".to_owned(),
969993
user: synapse_user_id,

0 commit comments

Comments
 (0)