File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -433,6 +433,23 @@ async fn migrate_devices(
433433 Ulid :: with_source ( rng) . into ( ) ) ;
434434 let created_at = Ulid :: from ( session_id) . datetime ( ) . into ( ) ;
435435
436+ // As we're using a real IP type in the MAS database, it is possible
437+ // that we encounter invalid IP addresses in the Synapse database.
438+ // In that case, we should ignore them, but still log a warning.
439+ let last_active_ip = ip. and_then ( |ip| {
440+ ip. parse ( )
441+ . map_err ( |e| {
442+ tracing:: warn!(
443+ error = & e as & dyn std:: error:: Error ,
444+ mxid = %synapse_user_id,
445+ %device_id,
446+ %ip,
447+ "Failed to parse device IP, ignoring"
448+ ) ;
449+ } )
450+ . ok ( )
451+ } ) ;
452+
436453 // TODO skip access tokens for deactivated users
437454 write_buffer
438455 . write (
@@ -445,7 +462,7 @@ async fn migrate_devices(
445462 created_at,
446463 is_synapse_admin : synapse_admins. contains ( & user_id) ,
447464 last_active_at : last_seen. map ( DateTime :: from) ,
448- last_active_ip : ip . map ( |ip| ip . parse ( ) ) . transpose ( ) . ok ( ) . flatten ( ) ,
465+ last_active_ip,
449466 user_agent,
450467 } ,
451468 )
You can’t perform that action at this time.
0 commit comments