From 47926418b5827d47baa1b73630be73d6127242c5 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 21 Nov 2017 23:30:30 -0500 Subject: [PATCH] Prevent subsequent "No valid session" errors from the recipient of an EndSession message. // FREEBIE --- Signal/src/Jobs/SessionResetJob.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Signal/src/Jobs/SessionResetJob.swift b/Signal/src/Jobs/SessionResetJob.swift index 935bd6e63..251c22743 100644 --- a/Signal/src/Jobs/SessionResetJob.swift +++ b/Signal/src/Jobs/SessionResetJob.swift @@ -33,6 +33,12 @@ class SessionResetJob: NSObject { let endSessionMessage = EndSessionMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: self.thread) self.messageSender.enqueue(endSessionMessage, success: { + 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 EndSession