mirror of https://github.com/oxen-io/session-ios
Tapping corrupted message opens "session reset" activity
This action was previously hidden under a secret longpress gesture in the fingerprint view controller. Ideally we'd never receive corrupted messages, but at the point we do, our sessions are out of whack, and the only recovery option is to reset. Let's help our users do that. * Resetting session sends END_SESSION message Otherwise the remote side wouldn't know we reset the session and will send us a message on the old ratchet. * Don't reset their identity key when resetting sender ratchet. * Updated translations // FREEBIEpull/1/head
parent
bd370f1de4
commit
c6a2fbff23
@ -0,0 +1,55 @@
|
||||
// Created by Michael Kirk on 10/31/16.
|
||||
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
import PromiseKit
|
||||
|
||||
@objc(OWSSessionResetJob)
|
||||
class SessionResetJob: NSObject {
|
||||
|
||||
let TAG = "SessionResetJob"
|
||||
|
||||
let recipientId: String
|
||||
let thread: TSThread
|
||||
let storageManager: TSStorageManager
|
||||
let messageSender: MessageSender
|
||||
|
||||
required init(recipientId: String, thread: TSThread, messageSender: MessageSender, storageManager: TSStorageManager) {
|
||||
self.thread = thread
|
||||
self.recipientId = recipientId
|
||||
self.messageSender = messageSender
|
||||
self.storageManager = storageManager
|
||||
}
|
||||
|
||||
func run() {
|
||||
Logger.info("\(TAG) Local user reset session.")
|
||||
|
||||
let endSessionMessage = EndSessionMessage(timestamp:NSDate.ows_millisecondTimeStamp(), in: thread)
|
||||
self.messageSender.send(endSessionMessage, success: {
|
||||
Logger.info("\(self.TAG) successfully sent EndSession<essage.")
|
||||
|
||||
Logger.info("\(self.TAG) deleting sessions for recipient: \(self.recipientId)")
|
||||
self.storageManager.deleteAllSessions(forContact: self.recipientId)
|
||||
|
||||
let message = TSInfoMessage(timestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
in: self.thread,
|
||||
messageType: TSInfoMessageType.typeSessionDidEnd)
|
||||
message?.save()
|
||||
}, failure: {error in
|
||||
Logger.error("\(self.TAG) failed to send EndSesionMessage with error: \(error.localizedDescription)")
|
||||
});
|
||||
}
|
||||
|
||||
class func run(corruptedMessage: TSErrorMessage, contactThread: TSContactThread, messageSender: MessageSender, storageManager: TSStorageManager) {
|
||||
let job = self.init(recipientId: contactThread.contactIdentifier(),
|
||||
thread: contactThread,
|
||||
messageSender: messageSender,
|
||||
storageManager: storageManager)
|
||||
job.run()
|
||||
}
|
||||
|
||||
class func run(recipientId: String, thread: TSThread, messageSender: MessageSender, storageManager: TSStorageManager) {
|
||||
let job = self.init(recipientId: recipientId, thread: thread, messageSender: messageSender, storageManager: storageManager)
|
||||
job.run()
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue