mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Patch bad mac issues
This commit is contained in:
parent
a51fcc0c04
commit
54988eeecf
3 changed files with 20 additions and 1 deletions
|
@ -20,7 +20,7 @@ public class LokiSessionResetImplementation : NSObject, SessionResetProtocol {
|
|||
guard let preKeyMessage = whisperMessage as? PreKeyWhisperMessage else { return }
|
||||
guard let storedPreKey = storage.getPreKeyRecord(forContact: recipientID, transaction: transaction) else {
|
||||
print("[Loki] Missing pre key bundle.")
|
||||
return
|
||||
throw Error.invalidPreKey
|
||||
}
|
||||
guard storedPreKey.id == preKeyMessage.prekeyID else {
|
||||
print("[Loki] Received a `PreKeyWhisperMessage` from an unknown source.")
|
||||
|
|
|
@ -141,6 +141,7 @@ public final class SessionManagementProtocol : NSObject {
|
|||
guard let thread = thread as? TSContactThread else {
|
||||
return print("[Loki] Can't restore session for non contact thread.")
|
||||
}
|
||||
guard thread.sessionResetStatus == .none else { return }
|
||||
// Send end session messages to the devices requiring session restoration
|
||||
let devices = thread.sessionRestoreDevices // TODO: Rename this to something that reads better
|
||||
for device in devices {
|
||||
|
|
|
@ -581,6 +581,24 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
|
|||
return;
|
||||
}
|
||||
|
||||
// FIXME: This is a temporary patch for bad mac issues. At least with this people will be able to message again. We have to figure out the root cause of the issue though.
|
||||
if ([decryptError userInfo][NSUnderlyingErrorKey] != nil) {
|
||||
NSDictionary *underlyingErrorUserInfo = [[decryptError userInfo][NSUnderlyingErrorKey] userInfo];
|
||||
if (underlyingErrorUserInfo[SCKExceptionWrapperUnderlyingExceptionKey] != nil) {
|
||||
NSException *underlyingUnderlyingError = underlyingErrorUserInfo[SCKExceptionWrapperUnderlyingExceptionKey];
|
||||
if ([[underlyingUnderlyingError reason] hasPrefix:@"Bad Mac!"]) {
|
||||
if ([underlyingError userInfo][@"kSenderRecipientIdKey"] != nil) {
|
||||
NSString *senderPublicKey = [underlyingError userInfo][@"kSenderRecipientIdKey"];
|
||||
TSContactThread *thread = [TSContactThread getThreadWithContactId:senderPublicKey transaction:transaction];
|
||||
if (thread != nil) {
|
||||
[thread addSessionRestoreDevice:senderPublicKey transaction:transaction];
|
||||
[LKSessionManagementProtocol startSessionResetInThread:thread transaction:transaction];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
failureBlock(underlyingError);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue