@@ -1037,7 +1037,7 @@ public final class SessionManager: NSObject, SessionManagerType {
10371037 if let session = backgroundUserSessions [ account. userIdentifier] {
10381038 WireLogger . sessionManager. debug ( " Session for \( account) is already loaded " )
10391039 return session
1040- } else if DeveloperFlag . multibackend . isOn {
1040+ } else {
10411041 do {
10421042 let loader = try UserSessionLoader (
10431043 account: account,
@@ -1135,8 +1135,6 @@ public final class SessionManager: NSObject, SessionManagerType {
11351135 )
11361136 return nil
11371137 }
1138- } else {
1139- return await setupUserSession ( account: account)
11401138 }
11411139 }
11421140
@@ -1169,132 +1167,6 @@ public final class SessionManager: NSObject, SessionManagerType {
11691167 }
11701168 }
11711169
1172- @MainActor
1173- private func setupUserSession( account: Account ) async -> ZMUserSession ? {
1174- let coreDataStack = CoreDataStack (
1175- account: account,
1176- applicationContainer: sharedContainerURL,
1177- dispatchGroup: dispatchGroup,
1178- localDomain: BackendInfo . domain,
1179- isFederationEnabled: BackendInfo . isFederationEnabled
1180- )
1181-
1182- if coreDataStack. needsMigration {
1183- await withCheckedContinuation { continuation in
1184- guard let delegate else {
1185- continuation. resume ( )
1186- return
1187- }
1188- delegate. sessionManagerWillMigrateAccount {
1189- continuation. resume ( )
1190- }
1191- }
1192- }
1193-
1194- do {
1195- try await coreDataStack. load ( )
1196- } catch {
1197- delegate? . sessionManagerDidFailToLoadDatabase ( error: error)
1198- return nil
1199- }
1200-
1201- let journal = Journal (
1202- userID: account. userIdentifier,
1203- storage: sharedUserDefaults
1204- )
1205-
1206- if shouldEnableSyncV2 ( journal: journal) {
1207- await enableSyncV2 (
1208- journal: journal,
1209- coreDataStack: coreDataStack
1210- )
1211- }
1212-
1213- let userSession = startBackgroundSession (
1214- for: account,
1215- with: coreDataStack,
1216- journal: journal,
1217- logFilesProvider: logFilesProvider
1218- )
1219-
1220- let migrationService = userSession. makeAppVersionMigrationService ( )
1221- if migrationService. isMigrationNeeded {
1222- await delegate? . sessionManagerWillMigrateAccount ( )
1223-
1224- do {
1225- try await migrationService. performAppMigrations ( )
1226- } catch {
1227- WireLogger . session. error (
1228- " Failed to perform app version migrations: \( String ( describing: error) ) "
1229- )
1230- }
1231- }
1232-
1233- var shouldTriggerSync = true
1234- do {
1235- try await userSession. migrateToConsumableNotificationsIfNeeded ( )
1236- } catch ZMUserSessionError . selfClientNotReady {
1237- // We skip trigger sync, because in this case (fresh login),
1238- // we don't have a registered client yet, so no consumable capability
1239- WireLogger . sync. warn ( " No consumable-notifications migrator available " )
1240- shouldTriggerSync = false
1241- } catch {
1242- return nil
1243- }
1244-
1245- if shouldTriggerSync {
1246- await userSession. triggerSync ( )
1247- }
1248-
1249- return userSession
1250- }
1251-
1252- private func shouldEnableSyncV2( journal: Journal ) -> Bool {
1253- guard let apiVersion = BackendInfo . apiVersion else {
1254- fatalError ( " api version unknown " )
1255- }
1256-
1257- let isAvailable = apiVersion >= . v8
1258- let isAlreadyEnabled = journal [ . isSyncV2Enabled]
1259- return isAvailable && !isAlreadyEnabled
1260- }
1261-
1262- private func enableSyncV2(
1263- journal: Journal ,
1264- coreDataStack: CoreDataStack
1265- ) async {
1266- guard let localDomain = BackendInfo . domain else {
1267- fatalError ( " local domain unknown " )
1268- }
1269-
1270- let dao : UpdateEventMigratorDAOProtocol = if #available( iOS 17 , * ) {
1271- ActorBasedUpdateEventMigratorDAO ( context: coreDataStack. eventContext)
1272- } else {
1273- UpdateEventMigratorDAO ( context: coreDataStack. eventContext)
1274- }
1275-
1276- let migrator = UpdateEventMigrator (
1277- dao: dao,
1278- localDomain: localDomain
1279- )
1280-
1281- do {
1282- if try await migrator. isMigrationNeeded ( ) {
1283- try await migrator. migrateLegacyUpdateEvents ( )
1284- // Since we only migrate some events, we require an
1285- // initial sync to ensure we didn't miss updates.
1286- journal [ . isInitialSyncRequired] = true
1287- } else {
1288- WireLogger . sync. debug ( " no migration needed " )
1289- }
1290-
1291- journal [ . isSyncV2Enabled] = true
1292-
1293- } catch {
1294- WireLogger . sync. critical ( " failed to migrate update events: \( error) " )
1295- }
1296- }
1297-
12981170 private func clearCRLExpirationDates( for account: Account ) {
12991171 let repository = CRLExpirationDatesRepository ( userID: account. userIdentifier)
13001172 repository. removeAllExpirationDates ( )
0 commit comments