From be743b6b23129a8108c4ec2cff874978840dac25 Mon Sep 17 00:00:00 2001 From: Frank Rotermund Date: Wed, 24 Sep 2025 08:22:14 +0200 Subject: [PATCH] feat: use username instead of displayname (MESSENGER-7565) --- .../Common/Recents/DataSources/RecentsDataSource.m | 2 +- bwi/MigrationAssistent/MigrationAssistant.swift | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m index 719ecb8c3..b696e5681 100644 --- a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m +++ b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m @@ -1899,7 +1899,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou MigrationAssistant *migrationAssistant = [[MigrationAssistant alloc] init]; - BOOL retVal = [migrationAssistant storeDisplaynameWithSession:session]; + BOOL retVal = [migrationAssistant storeUsernameWithSession:session]; if ( retVal == false) { MXLogError(@"[RecentsDataSource] shouldShowFeatureBanner could not store displaname for migration") } diff --git a/bwi/MigrationAssistent/MigrationAssistant.swift b/bwi/MigrationAssistent/MigrationAssistant.swift index 2c8170cbb..4ea9e8222 100644 --- a/bwi/MigrationAssistent/MigrationAssistant.swift +++ b/bwi/MigrationAssistent/MigrationAssistant.swift @@ -22,13 +22,16 @@ import MatrixSDK // reads user name and displayName from session and stores in shared keychain @objcMembers class MigrationAssistant : NSObject { - func storeDisplayname( session: MXSession ) -> Bool { + func storeUsername( session: MXSession ) -> Bool { var returnValue = false - if let displayname = session.myUser.displayName { - let ossStatus = SharedKeychain.save(account: "migration_displayname", value: displayname) - returnValue = ossStatus == errSecSuccess + if let fullID = session.myUser.userId { + let withoutAt = fullID.hasPrefix("@") ? String(fullID.dropFirst()) : fullID + if let username = withoutAt.split(separator: ":").first { + let ossStatus = SharedKeychain.save(account: "migration_username", value: String(username)) + returnValue = ossStatus == errSecSuccess + } } return returnValue