|  |  |  | @ -39,12 +39,23 @@ class SessionResetJob: NSObject { | 
		
	
		
			
				|  |  |  |  |                         // Otherwise if we send another message before them, they wont have the session to decrypt it. | 
		
	
		
			
				|  |  |  |  |                         self.storageManager.archiveAllSessions(forContact: self.recipientId) | 
		
	
		
			
				|  |  |  |  |                     } | 
		
	
		
			
				|  |  |  |  |                     Logger.info("\(self.TAG) successfully sent EndSession<essage.") | 
		
	
		
			
				|  |  |  |  |                     Logger.info("\(self.TAG) successfully sent EndSessionMessage.") | 
		
	
		
			
				|  |  |  |  |                     let message = TSInfoMessage(timestamp: NSDate.ows_millisecondTimeStamp(), | 
		
	
		
			
				|  |  |  |  |                                                 in: self.thread, | 
		
	
		
			
				|  |  |  |  |                                                 messageType: TSInfoMessageType.typeSessionDidEnd) | 
		
	
		
			
				|  |  |  |  |                     message.save() | 
		
	
		
			
				|  |  |  |  |                 }, failure: {error in | 
		
	
		
			
				|  |  |  |  |                     OWSDispatch.sessionStoreQueue().async { | 
		
	
		
			
				|  |  |  |  |                         // Even though this is the error handler - which means probably the recipient didn't receive the message | 
		
	
		
			
				|  |  |  |  |                         // there's a chance that our send did succeed and the server just timed out our repsonse or something. | 
		
	
		
			
				|  |  |  |  |                         // Since the cost of sending a future message using a session the recipient doesn't have is so high, | 
		
	
		
			
				|  |  |  |  |                         // we archive the session just in case. | 
		
	
		
			
				|  |  |  |  |                         // | 
		
	
		
			
				|  |  |  |  |                         // Archive the just-created session since the recipient should delete their corresponding | 
		
	
		
			
				|  |  |  |  |                         // session upon receiving and decrypting our EndSession message. | 
		
	
		
			
				|  |  |  |  |                         // Otherwise if we send another message before them, they wont have the session to decrypt it. | 
		
	
		
			
				|  |  |  |  |                         self.storageManager.archiveAllSessions(forContact: self.recipientId) | 
		
	
		
			
				|  |  |  |  |                     } | 
		
	
		
			
				|  |  |  |  |                     Logger.error("\(self.TAG) failed to send EndSessionMessage with error: \(error.localizedDescription)") | 
		
	
		
			
				|  |  |  |  |                 }) | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
	
		
			
				
					|  |  |  | 
 |