|
|
@ -33,12 +33,29 @@ class SessionResetJob: NSObject {
|
|
|
|
let endSessionMessage = EndSessionMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: self.thread)
|
|
|
|
let endSessionMessage = EndSessionMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: self.thread)
|
|
|
|
|
|
|
|
|
|
|
|
self.messageSender.enqueue(endSessionMessage, success: {
|
|
|
|
self.messageSender.enqueue(endSessionMessage, success: {
|
|
|
|
Logger.info("\(self.TAG) successfully sent EndSession<essage.")
|
|
|
|
OWSDispatch.sessionStoreQueue().async {
|
|
|
|
|
|
|
|
// 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.info("\(self.TAG) successfully sent EndSessionMessage.")
|
|
|
|
let message = TSInfoMessage(timestamp: NSDate.ows_millisecondTimeStamp(),
|
|
|
|
let message = TSInfoMessage(timestamp: NSDate.ows_millisecondTimeStamp(),
|
|
|
|
in: self.thread,
|
|
|
|
in: self.thread,
|
|
|
|
messageType: TSInfoMessageType.typeSessionDidEnd)
|
|
|
|
messageType: TSInfoMessageType.typeSessionDidEnd)
|
|
|
|
message.save()
|
|
|
|
message.save()
|
|
|
|
}, failure: {error in
|
|
|
|
}, 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)")
|
|
|
|
Logger.error("\(self.TAG) failed to send EndSessionMessage with error: \(error.localizedDescription)")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|