@@ -68,6 +68,12 @@ struct UsersMigrated {
68
68
user_localparts_to_uuid : HashMap < CompactString , Uuid > ,
69
69
}
70
70
71
+ struct DevicesMigrated {
72
+ /// Lookup table from `(user_id, device_id)` pairs to the
73
+ /// UUID of the `compat_session` in MAS
74
+ devices_to_uuid : HashMap < ( CompactString , CompactString ) , Uuid > ,
75
+ }
76
+
71
77
/// Performs a migration from Synapse's database to MAS' database.
72
78
///
73
79
/// # Panics
@@ -96,7 +102,7 @@ pub async fn migrate(
96
102
counts
97
103
. users
98
104
. try_into ( )
99
- . expect ( "More than usize::MAX users — wow !" ) ,
105
+ . expect ( "More than usize::MAX users — unable to handle this many !" ) ,
100
106
server_name,
101
107
rng,
102
108
)
@@ -121,6 +127,29 @@ pub async fn migrate(
121
127
)
122
128
. await ?;
123
129
130
+ let migrated_devices = migrate_devices (
131
+ synapse,
132
+ mas,
133
+ counts
134
+ . devices
135
+ . try_into ( )
136
+ . expect ( "More than usize::MAX devices — unable to handle this many!" ) ,
137
+ server_name,
138
+ rng,
139
+ & migrated_users. user_localparts_to_uuid ,
140
+ )
141
+ . await ?;
142
+
143
+ migrate_access_and_refresh_tokens (
144
+ synapse,
145
+ mas,
146
+ server_name,
147
+ rng,
148
+ & migrated_users. user_localparts_to_uuid ,
149
+ & migrated_devices. devices_to_uuid ,
150
+ )
151
+ . await ?;
152
+
124
153
Ok ( ( ) )
125
154
}
126
155
@@ -312,6 +341,36 @@ async fn migrate_external_ids(
312
341
313
342
Ok ( ( ) )
314
343
}
344
+ #[ tracing:: instrument( skip_all, level = Level :: INFO ) ]
345
+ async fn migrate_devices (
346
+ synapse : & mut SynapseReader < ' _ > ,
347
+ mas : & mut MasWriter < ' _ > ,
348
+ device_count_hint : usize ,
349
+ server_name : & str ,
350
+ rng : & mut impl RngCore ,
351
+ user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
352
+ ) -> Result < DevicesMigrated , Error > {
353
+ // TODO is 1:1 enough capacity for a HashMap?
354
+ let mut devices_to_uuid = HashMap :: with_capacity ( device_count_hint) ;
355
+
356
+ todo ! ( ) ;
357
+
358
+ Ok ( DevicesMigrated { devices_to_uuid } )
359
+ }
360
+
361
+ #[ tracing:: instrument( skip_all, level = Level :: INFO ) ]
362
+ async fn migrate_access_and_refresh_tokens (
363
+ synapse : & mut SynapseReader < ' _ > ,
364
+ mas : & mut MasWriter < ' _ > ,
365
+ server_name : & str ,
366
+ rng : & mut impl RngCore ,
367
+ user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
368
+ devices : & HashMap < ( CompactString , CompactString ) , Uuid > ,
369
+ ) -> Result < ( ) , Error > {
370
+ todo ! ( ) ;
371
+
372
+ Ok ( ( ) )
373
+ }
315
374
316
375
fn transform_user (
317
376
user : & SynapseUser ,
0 commit comments