Add manual session reset button

pull/260/head
nielsandriesse 4 years ago
parent 4a08e12752
commit 99229800a1

@ -1236,11 +1236,15 @@ typedef enum : NSUInteger {
}
- (void)restoreSession {
if (![self.thread isKindOfClass:TSContactThread.class]) { return; }
TSContactThread *thread = (TSContactThread *)self.thread;
__weak ConversationViewController *weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[LKSessionManagementProtocol startSessionResetInThread:self.thread transaction:transaction];
[thread addSessionRestoreDevice:thread.contactIdentifier transaction:transaction];
[LKSessionManagementProtocol startSessionResetInThread:thread transaction:transaction];
} error:nil];
[self updateSessionRestoreBanner];
[weakSelf updateSessionRestoreBanner];
});
}

@ -860,6 +860,15 @@ const CGFloat kIconViewLength = 24;
return cell;
}
actionBlock:nil]];
[mainSection addItem:
[OWSTableItem itemWithCustomCellBlock:^{
NSString *title = @"Reset Secure Session";
NSString *accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(OWSConversationSettingsViewController, @"reset_secure_session");
return [weakSelf disclosureCellWithName:title iconName:@"system_message_security" accessibilityIdentifier:accessibilityIdentifier];
}
actionBlock:^{ [weakSelf resetSecureSession]; }]
];
}
self.contents = contents;
@ -1421,6 +1430,26 @@ const CGFloat kIconViewLength = 24;
[self.conversationSettingsViewDelegate conversationSettingsDidRequestConversationSearch:self];
}
- (void)resetSecureSession
{
if (![self.thread isKindOfClass:TSContactThread.class]) { return; }
TSContactThread *thread = (TSContactThread *)self.thread;
__weak OWSConversationSettingsViewController *weakSelf = self;
NSString *message = @"This may help if you're having encryption problems in this conversation. Your messages will be kept.";
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Reset Secure Session?" message:message preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", @"") style:UIAlertActionStyleDefault handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"Reset" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
dispatch_async(dispatch_get_main_queue(), ^{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[thread addSessionRestoreDevice:thread.contactIdentifier transaction:transaction];
[LKSessionManagementProtocol startSessionResetInThread:thread transaction:transaction];
} error:nil];
[weakSelf.navigationController popViewControllerAnimated:YES];
});
}]];
[self presentViewController:alert animated:YES completion:nil];
}
#pragma mark - Notifications
- (void)identityStateDidChange:(NSNotification *)notification

@ -581,7 +581,7 @@ 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.
// Attempt to recover automatically
if ([decryptError userInfo][NSUnderlyingErrorKey] != nil) {
NSDictionary *underlyingErrorUserInfo = [[decryptError userInfo][NSUnderlyingErrorKey] userInfo];
if (underlyingErrorUserInfo[SCKExceptionWrapperUnderlyingExceptionKey] != nil) {

Loading…
Cancel
Save