diff --git a/wire-ios-data-model/Resources/Databases Changelog.md b/wire-ios-data-model/Resources/Databases Changelog.md index d9b8ab5eedc..b8bd679ed69 100644 --- a/wire-ios-data-model/Resources/Databases Changelog.md +++ b/wire-ios-data-model/Resources/Databases Changelog.md @@ -4,6 +4,10 @@ As it is hard to spot changes from version to version of database models (.xcdat ## zmessaging +### 2.121.0 + +Removed `pushToken` attribute from `UserClient`. + ### 2.120.0 PostAction to fix issue with federation migration. It triggers a resyncResources to make sure users and conversations get the domain. diff --git a/wire-ios-data-model/Resources/zmessaging.xcdatamodeld/.xccurrentversion b/wire-ios-data-model/Resources/zmessaging.xcdatamodeld/.xccurrentversion index f75339113f5..8a4fc205adf 100644 --- a/wire-ios-data-model/Resources/zmessaging.xcdatamodeld/.xccurrentversion +++ b/wire-ios-data-model/Resources/zmessaging.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - zmessaging2.120.0.xcdatamodel + zmessaging2.121.0.xcdatamodel diff --git a/wire-ios-data-model/Resources/zmessaging.xcdatamodeld/zmessaging2.121.0.xcdatamodel/contents b/wire-ios-data-model/Resources/zmessaging.xcdatamodeld/zmessaging2.121.0.xcdatamodel/contents new file mode 100644 index 00000000000..1b82c231817 --- /dev/null +++ b/wire-ios-data-model/Resources/zmessaging.xcdatamodeld/zmessaging2.121.0.xcdatamodel/contents @@ -0,0 +1,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wire-ios-data-model/Source/ManagedObjectContext/Migration/CoreDataMessagingMigrationVersion.swift b/wire-ios-data-model/Source/ManagedObjectContext/Migration/CoreDataMessagingMigrationVersion.swift index 5632882ac61..477b72d03e6 100644 --- a/wire-ios-data-model/Source/ManagedObjectContext/Migration/CoreDataMessagingMigrationVersion.swift +++ b/wire-ios-data-model/Source/ManagedObjectContext/Migration/CoreDataMessagingMigrationVersion.swift @@ -29,6 +29,7 @@ enum CoreDataMessagingMigrationVersion: String, CoreDataMigrationVersion { // MARK: - // Note: add new versions here in first position! + case v121 = "zmessaging2.121.0" case v120 = "zmessaging2.120.0" case v119 = "zmessaging2.119.0" case v118 = "zmessaging2.118.0" @@ -73,10 +74,12 @@ enum CoreDataMessagingMigrationVersion: String, CoreDataMigrationVersion { var nextVersion: Self? { switch self { - case .v120: + case .v121: nil + case .v120: + .v121 case .v119: - .v120 + .v120 // destination version runs custom migration actions case .v116, .v117, .v118: .v119 case .v115, diff --git a/wire-ios-data-model/Source/ManagedObjectContext/NSManagedObjectContext+BackupImport.swift b/wire-ios-data-model/Source/ManagedObjectContext/NSManagedObjectContext+BackupImport.swift index faff9a546da..b4a89145b2c 100644 --- a/wire-ios-data-model/Source/ManagedObjectContext/NSManagedObjectContext+BackupImport.swift +++ b/wire-ios-data-model/Source/ManagedObjectContext/NSManagedObjectContext+BackupImport.swift @@ -23,8 +23,6 @@ extension NSManagedObjectContext { /// Prepare a backed up database for being imported, deleting self client, push token etc. func prepareToImportBackup() { setPersistentStoreMetadata(nil as Data?, key: ZMPersistedClientIdKey) - setPersistentStoreMetadata(nil as Data?, key: PersistentMetadataKey.pushToken.rawValue) - setPersistentStoreMetadata(nil as Data?, key: PersistentMetadataKey.pushKitToken.rawValue) setPersistentStoreMetadata(nil as Data?, key: PersistentMetadataKey.lastUpdateEventID.rawValue) _ = makeMetadataPersistent() } diff --git a/wire-ios-data-model/Source/Model/PersistentMetadataKeys.swift b/wire-ios-data-model/Source/Model/PersistentMetadataKeys.swift index b070916bf54..ce9326e30e5 100644 --- a/wire-ios-data-model/Source/Model/PersistentMetadataKeys.swift +++ b/wire-ios-data-model/Source/Model/PersistentMetadataKeys.swift @@ -16,13 +16,10 @@ // along with this program. If not, see http://www.gnu.org/licenses/. // -import Foundation - public enum PersistentMetadataKey: String { case lastUpdateEventID = "LastUpdateEventID" - case pushToken - case pushKitToken = "ZMPushKitToken" case encryptMessagesAtRest case appLock + } diff --git a/wire-ios-data-model/Source/Model/UserClient/UserClient.swift b/wire-ios-data-model/Source/Model/UserClient/UserClient.swift index 6ac64dfe50e..18fc047be87 100644 --- a/wire-ios-data-model/Source/Model/UserClient/UserClient.swift +++ b/wire-ios-data-model/Source/Model/UserClient/UserClient.swift @@ -69,51 +69,6 @@ public class UserClient: ZMManagedObject, UserClientType { @NSManaged public var needsSessionMigration: Bool @NSManaged public var discoveredByMessage: ZMOTRMessage? - private enum Keys { - static let PushToken = "pushToken" - static let DeviceClass = "deviceClass" - } - - // DO NOT USE THIS PROPERTY. - // - // Storing the push token on the self user client is now deprecated. - // From now on, we store the push token in the user defaults and is - // no longer the responsibility of the data model project. We keep - // it here so that it can still be fetched when migrating the token - // to user defaults, it can be deleted after some time. - - @NSManaged private var primitivePushToken: Data? - private var pushToken: PushToken? { - get { - willAccessValue(forKey: Keys.PushToken) - let token: PushToken? = if let data = primitivePushToken { - try? JSONDecoder().decode(PushToken.self, from: data) - } else { - nil - } - didAccessValue(forKey: Keys.PushToken) - return token - } - set { - if newValue != pushToken { - willChangeValue(forKey: Keys.PushToken) - primitivePushToken = try? JSONEncoder().encode(newValue) - didChangeValue(forKey: Keys.PushToken) - } - } - - } - - /// Fetches and removes the old push token from the self client. - /// - /// - returns: the legacy push token if it exists. - - public func retrieveLegacyPushToken() -> PushToken? { - guard let token = pushToken else { return nil } - pushToken = nil - return token - } - /// Clients that are trusted by self client. @NSManaged public var trustedClients: Set diff --git a/wire-ios-data-model/Tests/Resources/store2-121-0.wiredatabase b/wire-ios-data-model/Tests/Resources/store2-121-0.wiredatabase new file mode 100644 index 00000000000..51b0747d9ce Binary files /dev/null and b/wire-ios-data-model/Tests/Resources/store2-121-0.wiredatabase differ diff --git a/wire-ios-data-model/Tests/Source/ManagedObjectContext/CoreDataStackTests+Backup.swift b/wire-ios-data-model/Tests/Source/ManagedObjectContext/CoreDataStackTests+Backup.swift index 296bfea4d39..2ea17d7af30 100644 --- a/wire-ios-data-model/Tests/Source/ManagedObjectContext/CoreDataStackTests+Backup.swift +++ b/wire-ios-data-model/Tests/Source/ManagedObjectContext/CoreDataStackTests+Backup.swift @@ -16,7 +16,6 @@ // along with this program. If not, see http://www.gnu.org/licenses/. // -import Foundation import XCTest @testable import WireDataModel @@ -284,8 +283,6 @@ final class CoreDataStackTests_Backup: DatabaseBaseTest { // Set metadata on DB which we expect to be cleared when importing from a backup directory.viewContext.setPersistentStoreMetadata("1234567890", key: ZMPersistedClientIdKey) - directory.viewContext.setPersistentStoreMetadata("1234567890", key: PersistentMetadataKey.pushToken.rawValue) - directory.viewContext.setPersistentStoreMetadata("1234567890", key: PersistentMetadataKey.pushKitToken.rawValue) directory.viewContext.setPersistentStoreMetadata( "1234567890", key: PersistentMetadataKey.lastUpdateEventID.rawValue @@ -308,14 +305,6 @@ final class CoreDataStackTests_Backup: DatabaseBaseTest { // then XCTAssertNil(importedDirectory.viewContext.persistentStoreMetadata(forKey: ZMPersistedClientIdKey)) - XCTAssertNil( - importedDirectory.viewContext - .persistentStoreMetadata(forKey: PersistentMetadataKey.pushToken.rawValue) - ) - XCTAssertNil( - importedDirectory.viewContext - .persistentStoreMetadata(forKey: PersistentMetadataKey.pushKitToken.rawValue) - ) XCTAssertNil( importedDirectory.viewContext .persistentStoreMetadata(forKey: PersistentMetadataKey.lastUpdateEventID.rawValue) diff --git a/wire-ios-data-model/Tests/Source/ManagedObjectContext/DatabaseMigrationTests.swift b/wire-ios-data-model/Tests/Source/ManagedObjectContext/DatabaseMigrationTests.swift index aa5df2136ed..4ac6b84d507 100644 --- a/wire-ios-data-model/Tests/Source/ManagedObjectContext/DatabaseMigrationTests.swift +++ b/wire-ios-data-model/Tests/Source/ManagedObjectContext/DatabaseMigrationTests.swift @@ -18,6 +18,7 @@ // import XCTest + @testable import WireDataModel final class DatabaseMigrationTests: DatabaseBaseTest { @@ -121,7 +122,7 @@ final class DatabaseMigrationTests: DatabaseBaseTest { "- Run the test, until you hit the assertion\n" + "- **WHILE THE TEST IS PAUSED** on the assertion, do the following:\n" + "- open the the folder in Finder by typing this command in your terminal. IT WILL NOT WORK IF THE TEST IS NOT PAUSED!!!.\n" + - "\t cp \"\(currentDatabaseURL.path)\" wire-ios-data-model/Tests/Resources/store\(fixtureVersion).wiredatabase\n\n" + + "\t cp -v \"\(currentDatabaseURL.path)\" wire-ios-data-model/Tests/Resources/store\(fixtureVersion).wiredatabase\n\n" + "- The command will copy a file to `WireDataModel/Tests/Resources/store\(fixtureVersion).wiredatabase`\n" + "- Add it to WireDataModel project with the other stores\n\n" ) diff --git a/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj b/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj index ae6979a3486..b7908ff3956 100644 --- a/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj +++ b/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj @@ -298,6 +298,7 @@ 5966D8322BD6AA8200305BBC /* UserPropertyNormalizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5966D8312BD6AA8200305BBC /* UserPropertyNormalizer.swift */; }; 5966D8342BD6ADCA00305BBC /* UserPropertyNormalizerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5966D8332BD6ADCA00305BBC /* UserPropertyNormalizerTests.swift */; }; 5966D8362BD6AF1700305BBC /* UserPropertyNormalizationResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5966D8352BD6AF1700305BBC /* UserPropertyNormalizationResult.swift */; }; + 5979E8482D478DD20051080F /* store2-121-0.wiredatabase in Resources */ = {isa = PBXBuildFile; fileRef = 5979E8472D478DD20051080F /* store2-121-0.wiredatabase */; }; 597A3BB42B6416CA0020E337 /* Availability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 597A3BB32B6416CA0020E337 /* Availability.swift */; }; 597A3BB72B6418170020E337 /* Availability+WireProtos.swift in Sources */ = {isa = PBXBuildFile; fileRef = 597A3BB62B6418170020E337 /* Availability+WireProtos.swift */; }; 597B70C72B03C6A5006C2121 /* UpdateConversationProtocolAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 597B70C62B03C6A5006C2121 /* UpdateConversationProtocolAction.swift */; }; @@ -1207,6 +1208,7 @@ 591F8A012B8CB4DE00D562A6 /* IsSelfUserE2EICertifiedUseCaseProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IsSelfUserE2EICertifiedUseCaseProtocol.swift; sourceTree = ""; }; 591F8A032B8CB4EF00D562A6 /* IsSelfUserE2EICertifiedUseCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IsSelfUserE2EICertifiedUseCase.swift; sourceTree = ""; }; 591F8A052B8CB81400D562A6 /* IsSelfUserE2EICertifiedUseCaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IsSelfUserE2EICertifiedUseCaseTests.swift; sourceTree = ""; }; + 5930D9C22D43BC33009E3514 /* zmessaging2.121.0.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = zmessaging2.121.0.xcdatamodel; sourceTree = ""; }; 5952B89A2BA3179100C48B01 /* MLSClientID+random.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MLSClientID+random.swift"; sourceTree = ""; }; 5952B89C2BA3189F00C48B01 /* MLSConferenceInfo+random.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MLSConferenceInfo+random.swift"; sourceTree = ""; }; 5966D82D2BD6A33F00305BBC /* UserPropertyValidating.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserPropertyValidating.swift; sourceTree = ""; }; @@ -1215,6 +1217,7 @@ 5966D8332BD6ADCA00305BBC /* UserPropertyNormalizerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPropertyNormalizerTests.swift; sourceTree = ""; }; 5966D8352BD6AF1700305BBC /* UserPropertyNormalizationResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPropertyNormalizationResult.swift; sourceTree = ""; }; 5972D9792B480E790089D1D3 /* CoreCryptoProtocolExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreCryptoProtocolExt.swift; sourceTree = ""; }; + 5979E8472D478DD20051080F /* store2-121-0.wiredatabase */ = {isa = PBXFileReference; lastKnownFileType = file; path = "store2-121-0.wiredatabase"; sourceTree = ""; }; 597A3BB32B6416CA0020E337 /* Availability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Availability.swift; sourceTree = ""; }; 597A3BB62B6418170020E337 /* Availability+WireProtos.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Availability+WireProtos.swift"; sourceTree = ""; }; 597B70C62B03C6A5006C2121 /* UpdateConversationProtocolAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateConversationProtocolAction.swift; sourceTree = ""; }; @@ -3703,8 +3706,9 @@ F9C9A83D1CAEDBC40039E10C /* Resources */ = { isa = PBXGroup; children = ( - 01586D432CAED2B200C3BCE1 /* store2-119-0.wiredatabase */, + 5979E8472D478DD20051080F /* store2-121-0.wiredatabase */, 017B55A82CFFC310005FFBD4 /* store2-120-0.wiredatabase */, + 01586D432CAED2B200C3BCE1 /* store2-119-0.wiredatabase */, E6BB79582C36EBE0003B821B /* store2-118-0.wiredatabase */, 16058B2D2BDBAF73003C82C2 /* store2-117-0.wiredatabase */, 162F85AA2BC58DF8007E2CB6 /* store2-116-0.wiredatabase */, @@ -3991,6 +3995,7 @@ 54AA3C9924ED2CE700FE1F94 /* store2-84-0.wiredatabase in Resources */, 5495BC431E019F1B004253ED /* audio.m4a in Resources */, 4058AAA62AAA017F0013DE71 /* store2-109-0.wiredatabase in Resources */, + 5979E8482D478DD20051080F /* store2-121-0.wiredatabase in Resources */, 54BAB40B24A4FA0800EBC400 /* store2-82-0.wiredatabase in Resources */, EEB5DE112837BD52009B4741 /* store2-101-0.wiredatabase in Resources */, 017B55A92CFFC310005FFBD4 /* store2-120-0.wiredatabase in Resources */, @@ -5266,6 +5271,7 @@ E6F443042B16294000D2B08A /* zmessaging.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + 5930D9C22D43BC33009E3514 /* zmessaging2.121.0.xcdatamodel */, 017B55732CFFA599005FFBD4 /* zmessaging2.120.0.xcdatamodel */, 01586D3F2CAECE8B00C3BCE1 /* zmessaging2.119.0.xcdatamodel */, E6BB79552C36DDA9003B821B /* zmessaging2.118.0.xcdatamodel */, @@ -5308,7 +5314,7 @@ E6F443102B16294000D2B08A /* zmessaging2.81.0.xcdatamodel */, E6F443182B16294000D2B08A /* zmessaging2.80.0.xcdatamodel */, ); - currentVersion = 017B55732CFFA599005FFBD4 /* zmessaging2.120.0.xcdatamodel */; + currentVersion = 5930D9C22D43BC33009E3514 /* zmessaging2.121.0.xcdatamodel */; path = zmessaging.xcdatamodeld; sourceTree = ""; versionGroupType = wrapper.xcdatamodel;