Backup export needs to verify that we have a valid account.

pull/1/head
Matthew Chen 7 years ago
parent 2915c533b2
commit 59fc232128

@ -187,41 +187,28 @@ NSString *const kOWSBackup_ExportDatabaseKeySpec = @"kOWSBackup_ExportDatabaseKe
OWSProdLogAndFail(@"%@ Could not create jobTempDirPath.", self.logTag); OWSProdLogAndFail(@"%@ Could not create jobTempDirPath.", self.logTag);
return completion(NO); return completion(NO);
} }
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
completion(YES);
});
// TSRequest *currentSignedPreKey = [OWSRequestFactory currentSignedPreKeyRequest]; // We need to verify that we have a valid account.
// [[TSNetworkManager sharedManager] makeRequest:currentSignedPreKey // Otherwise, if we re-register on another device, we
// success:^(NSURLSessionDataTask *task, NSDictionary *responseObject) { // continue to backup on our old device, overwriting
// NSString *keyIdDictKey = @"keyId"; // backups from the new device.
// NSNumber *keyId = [responseObject objectForKey:keyIdDictKey];
// OWSAssert(keyId);
//
// OWSPrimaryStorage *primaryStorage = [OWSPrimaryStorage
// sharedManager]; NSNumber *currentSignedPrekeyId = [primaryStorage
// currentSignedPrekeyId];
//
// if (!keyId || !currentSignedPrekeyId || ![currentSignedPrekeyId
// isEqualToNumber:keyId]) {
// DDLogError(
// @"%@ Local and service 'current signed prekey ids'
// did not match. %@ == %@ == %d.", self.logTag, keyId,
// currentSignedPrekeyId,
// [currentSignedPrekeyId isEqualToNumber:keyId]);
// }
// }
// failure:^(NSURLSessionDataTask *task, NSError *error) {
// if (!IsNSErrorNetworkFailure(error)) {
// OWSProdError([OWSAnalyticsEvents
// errorPrekeysCurrentSignedPrekeyRequestFailed]);
// }
// DDLogWarn(@"%@ Could not retrieve current signed key from the
// service.", self.logTag);
// //
// // Mark the prekeys as _NOT_ checked on failure. // We use an arbitrary request that requires authentication
// [self markPreKeysAsNotChecked]; // to verify our account state.
// }]; TSRequest *currentSignedPreKey = [OWSRequestFactory currentSignedPreKeyRequest];
[[TSNetworkManager sharedManager] makeRequest:currentSignedPreKey
success:^(NSURLSessionDataTask *task, NSDictionary *responseObject) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
completion(YES);
});
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
// TODO: We may want to surface this in the UI.
DDLogError(@"%@ could not verify account status: %@.", self.logTag, error);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
completion(NO);
});
}];
} }
- (void)exportDatabase:(OWSBackupJobBoolCompletion)completion - (void)exportDatabase:(OWSBackupJobBoolCompletion)completion

Loading…
Cancel
Save