You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
	
	
		
			
				
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @objc(SNContactsMigration) | 
					
						
							|  |  |  | public class ContactsMigration : OWSDatabaseMigration { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @objc | 
					
						
							|  |  |  |     class func migrationId() -> String { | 
					
						
							|  |  |  |         return "001" | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     override public func runUp(completion: @escaping OWSDatabaseMigrationCompletion) { | 
					
						
							|  |  |  |         self.doMigrationAsync(completion: completion) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     private func doMigrationAsync(completion: @escaping OWSDatabaseMigrationCompletion) { | 
					
						
							|  |  |  |         var contacts: [Contact] = [] | 
					
						
							|  |  |  |         TSContactThread.enumerateCollectionObjects { object, _ in | 
					
						
							|  |  |  |             guard let thread = object as? TSContactThread else { return } | 
					
						
							|  |  |  |             let sessionID = thread.contactSessionID() | 
					
						
							|  |  |  |             if let contact = Storage.shared.getContact(with: sessionID) { | 
					
						
							|  |  |  |                 contact.isTrusted = true | 
					
						
							|  |  |  |                 contacts.append(contact) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         Storage.write(with: { transaction in | 
					
						
							|  |  |  |             contacts.forEach { contact in | 
					
						
							|  |  |  |                 Storage.shared.setContact(contact, using: transaction) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             self.save(with: transaction) // Intentionally capture self | 
					
						
							|  |  |  |         }, completion: { | 
					
						
							|  |  |  |             completion() | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |