|  |  |  | @ -41,7 +41,7 @@ public final class SyncMessagesProtocol : NSObject { | 
		
	
		
			
				|  |  |  |  |         TSContactThread.enumerateCollectionObjects { object, _ in | 
		
	
		
			
				|  |  |  |  |             guard let thread = object as? TSContactThread else { return } | 
		
	
		
			
				|  |  |  |  |             let hexEncodedPublicKey = thread.contactIdentifier() | 
		
	
		
			
				|  |  |  |  |             guard thread.isContactFriend && thread.shouldThreadBeVisible && !thread.isForceHidden else { return } | 
		
	
		
			
				|  |  |  |  |             guard thread.isContactFriend && thread.shouldThreadBeVisible && !thread.isSlaveThread else { return } | 
		
	
		
			
				|  |  |  |  |             friends.append(SignalAccount(recipientId: hexEncodedPublicKey)) | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         friends.append(SignalAccount(recipientId: getUserHexEncodedPublicKey())) // TODO: Are we sure about this? | 
		
	
	
		
			
				
					|  |  |  | @ -61,7 +61,7 @@ public final class SyncMessagesProtocol : NSObject { | 
		
	
		
			
				|  |  |  |  |         var groups: [TSGroupThread] = [] | 
		
	
		
			
				|  |  |  |  |         TSGroupThread.enumerateCollectionObjects { object, _ in | 
		
	
		
			
				|  |  |  |  |             guard let group = object as? TSGroupThread, group.groupModel.groupType == .closedGroup, | 
		
	
		
			
				|  |  |  |  |                 group.shouldThreadBeVisible, !group.isForceHidden else { return } | 
		
	
		
			
				|  |  |  |  |                 group.shouldThreadBeVisible else { return } | 
		
	
		
			
				|  |  |  |  |             groups.append(group) | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         let syncManager = SSKEnvironment.shared.syncManager | 
		
	
	
		
			
				
					|  |  |  | @ -168,30 +168,23 @@ public final class SyncMessagesProtocol : NSObject { | 
		
	
		
			
				|  |  |  |  |         // Try to establish sessions | 
		
	
		
			
				|  |  |  |  |         for hexEncodedPublicKey in hexEncodedPublicKeys { | 
		
	
		
			
				|  |  |  |  |             // We don't update the friend request status; that's done in OWSMessageSender.sendMessage(_:) | 
		
	
		
			
				|  |  |  |  |             let thread = TSContactThread.getOrCreateThread(withContactId: hexEncodedPublicKey, transaction: transaction) | 
		
	
		
			
				|  |  |  |  |             let friendRequestStatus = storage.getFriendRequestStatus(for: hexEncodedPublicKey, transaction: transaction) | 
		
	
		
			
				|  |  |  |  |             switch friendRequestStatus { | 
		
	
		
			
				|  |  |  |  |             case .none, .requestExpired: | 
		
	
		
			
				|  |  |  |  |                 let messageSender = SSKEnvironment.shared.messageSender | 
		
	
		
			
				|  |  |  |  |                 // We need to send the FR message to all of the user's devices as the contact sync message excludes slave devices | 
		
	
		
			
				|  |  |  |  |                 let autoGeneratedFRMessage = MultiDeviceProtocol.getAutoGeneratedMultiDeviceFRMessage(for: hexEncodedPublicKey, in: transaction) | 
		
	
		
			
				|  |  |  |  |                 thread.isForceHidden = true | 
		
	
		
			
				|  |  |  |  |                 thread.save(with: transaction) | 
		
	
		
			
				|  |  |  |  |                 // This takes into account multi device | 
		
	
		
			
				|  |  |  |  |                 messageSender.send(autoGeneratedFRMessage, success: { | 
		
	
		
			
				|  |  |  |  |                     DispatchQueue.main.async { | 
		
	
		
			
				|  |  |  |  |                         storage.dbReadWriteConnection.readWrite { transaction in | 
		
	
		
			
				|  |  |  |  |                             autoGeneratedFRMessage.remove(with: transaction) | 
		
	
		
			
				|  |  |  |  |                             thread.isForceHidden = false | 
		
	
		
			
				|  |  |  |  |                             thread.save(with: transaction) | 
		
	
		
			
				|  |  |  |  |                         } | 
		
	
		
			
				|  |  |  |  |                     } | 
		
	
		
			
				|  |  |  |  |                 }, failure: { error in | 
		
	
		
			
				|  |  |  |  |                     DispatchQueue.main.async { | 
		
	
		
			
				|  |  |  |  |                         storage.dbReadWriteConnection.readWrite { transaction in | 
		
	
		
			
				|  |  |  |  |                             autoGeneratedFRMessage.remove(with: transaction) | 
		
	
		
			
				|  |  |  |  |                             thread.isForceHidden = false | 
		
	
		
			
				|  |  |  |  |                             thread.save(with: transaction) | 
		
	
		
			
				|  |  |  |  |                         } | 
		
	
		
			
				|  |  |  |  |                     } | 
		
	
		
			
				|  |  |  |  |                 }) | 
		
	
	
		
			
				
					|  |  |  | 
 |