diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist
index 9f2b3332f..f77e55a0b 100644
--- a/Signal/Signal-Info.plist
+++ b/Signal/Signal-Info.plist
@@ -6,14 +6,10 @@
CarthageVersion
0.36.0
- DateTime
- Tue Oct 27 21:55:52 UTC 2020
OSXVersion
10.15.6
WebRTCCommit
1445d719bf05280270e9f77576f80f973fd847f8 M73
- XCodeVersion
- 1200.1210
CFBundleDevelopmentRegion
en
diff --git a/Signal/src/Jobs/SessionResetJob.swift b/Signal/src/Jobs/SessionResetJob.swift
index 9cb4a2e1e..8c67923d2 100644
--- a/Signal/src/Jobs/SessionResetJob.swift
+++ b/Signal/src/Jobs/SessionResetJob.swift
@@ -112,7 +112,7 @@ public class SessionResetOperation: OWSOperation, DurableOperation {
* We don't want to delete the session. Ref: SignalServiceKit/Loki/Docs/SessionReset.md
* ================
if firstAttempt {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
Logger.info("deleting sessions for recipient: \(self.recipientId)")
self.primaryStorage.deleteAllSessions(forContact: self.recipientId, protocolContext: transaction)
}
@@ -127,7 +127,7 @@ public class SessionResetOperation: OWSOperation, DurableOperation {
return self.messageSender.sendPromise(message: endSessionMessage)
}.done {
Logger.info("successfully sent EndSessionMessage.")
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
// 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.
@@ -160,7 +160,7 @@ public class SessionResetOperation: OWSOperation, DurableOperation {
}
override public func didSucceed() {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
self.durableOperationDelegate?.durableOperationDidSucceed(self, transaction: transaction)
}
}
@@ -168,7 +168,7 @@ public class SessionResetOperation: OWSOperation, DurableOperation {
override public func didReportError(_ error: Error) {
Logger.debug("remainingRetries: \(self.remainingRetries)")
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
self.durableOperationDelegate?.durableOperation(self, didReportError: error, transaction: transaction)
}
}
@@ -192,7 +192,7 @@ public class SessionResetOperation: OWSOperation, DurableOperation {
override public func didFail(error: Error) {
Logger.error("failed to send EndSessionMessage with error: \(error.localizedDescription)")
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
self.durableOperationDelegate?.durableOperation(self, didFailWithError: error, transaction: transaction)
// Even though this is the failure handler - which means probably the recipient didn't receive the message
diff --git a/Signal/src/Loki/View Controllers/DeviceLinkingModal.swift b/Signal/src/Loki/View Controllers/DeviceLinkingModal.swift
index ad071d9f9..bddec1370 100644
--- a/Signal/src/Loki/View Controllers/DeviceLinkingModal.swift
+++ b/Signal/src/Loki/View Controllers/DeviceLinkingModal.swift
@@ -185,7 +185,7 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
FileServerAPI.addDeviceLink(signedDeviceLink).done(on: DispatchQueue.main) { [weak self] in
SSKEnvironment.shared.messageSender.send(linkingAuthorizationMessage, success: {
let slavePublicKey = deviceLink.slave.publicKey
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
let thread = TSContactThread.getOrCreateThread(withContactId: slavePublicKey, transaction: transaction)
thread.save(with: transaction)
}
@@ -247,7 +247,7 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
session.markLinkingRequestAsProcessed() // Only relevant in master mode
delegate?.handleDeviceLinkingModalDismissed() // Only relevant in slave mode
if let deviceLink = deviceLink {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
OWSPrimaryStorage.shared().removePreKeyBundle(forContact: deviceLink.slave.publicKey, transaction: transaction)
}
}
diff --git a/Signal/src/Loki/View Controllers/DeviceLinksVC.swift b/Signal/src/Loki/View Controllers/DeviceLinksVC.swift
index 3901eb4c9..8eccf4017 100644
--- a/Signal/src/Loki/View Controllers/DeviceLinksVC.swift
+++ b/Signal/src/Loki/View Controllers/DeviceLinksVC.swift
@@ -146,7 +146,7 @@ final class DeviceLinksVC : BaseVC, UITableViewDataSource, UITableViewDelegate,
let unlinkDeviceMessage = UnlinkDeviceMessage(thread: thread)
SSKEnvironment.shared.messageSender.send(unlinkDeviceMessage, success: {
let storage = OWSPrimaryStorage.shared()
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
storage.removePreKeyBundle(forContact: linkedDevicePublicKey, transaction: transaction)
storage.deleteAllSessions(forContact: linkedDevicePublicKey, protocolContext: transaction)
for groupPublicKey in Storage.getUserClosedGroupPublicKeys() {
@@ -157,7 +157,7 @@ final class DeviceLinksVC : BaseVC, UITableViewDataSource, UITableViewDelegate,
}, failure: { _ in
print("[Loki] Failed to send unlink device message.")
let storage = OWSPrimaryStorage.shared()
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
storage.removePreKeyBundle(forContact: linkedDevicePublicKey, transaction: transaction)
storage.deleteAllSessions(forContact: linkedDevicePublicKey, protocolContext: transaction)
for groupPublicKey in Storage.getUserClosedGroupPublicKeys() {
diff --git a/Signal/src/Loki/View Controllers/EditClosedGroupVC.swift b/Signal/src/Loki/View Controllers/EditClosedGroupVC.swift
index 3ae6393eb..472cfe9e9 100644
--- a/Signal/src/Loki/View Controllers/EditClosedGroupVC.swift
+++ b/Signal/src/Loki/View Controllers/EditClosedGroupVC.swift
@@ -252,7 +252,7 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega
return popToConversationVC(self)
}
ModalActivityIndicatorViewController.present(fromViewController: navigationController!, canCancel: false) { [weak self] _ in
- try! Storage.writeSync { [weak self] transaction in
+ Storage.writeSync { [weak self] transaction in
ClosedGroupsProtocol.update(groupPublicKey, with: members, name: name, transaction: transaction).done(on: DispatchQueue.main) {
guard let self = self else { return }
self.dismiss(animated: true, completion: nil) // Dismiss the loader
diff --git a/Signal/src/Loki/View Controllers/HomeVC.swift b/Signal/src/Loki/View Controllers/HomeVC.swift
index 3a742ab48..07ab7c77b 100644
--- a/Signal/src/Loki/View Controllers/HomeVC.swift
+++ b/Signal/src/Loki/View Controllers/HomeVC.swift
@@ -383,7 +383,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol
let delete = UITableViewRowAction(style: .destructive, title: NSLocalizedString("TXT_DELETE_TITLE", comment: "")) { [weak self] _, _ in
let alert = UIAlertController(title: NSLocalizedString("CONVERSATION_DELETE_CONFIRMATION_ALERT_TITLE", comment: ""), message: NSLocalizedString("CONVERSATION_DELETE_CONFIRMATION_ALERT_MESSAGE", comment: ""), preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("TXT_DELETE_TITLE", comment: ""), style: .destructive) { _ in
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
if let publicChat = publicChat {
var messageIDs: Set = []
thread.enumerateInteractions(with: transaction) { interaction, _ in
@@ -399,7 +399,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol
let groupID = thread.groupModel.groupId
let groupPublicKey = LKGroupUtilities.getDecodedGroupID(groupID)
let _ = ClosedGroupsProtocol.leave(groupPublicKey, using: transaction).ensure {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
thread.removeAllThreadInteractions(with: transaction)
thread.remove(with: transaction)
}
diff --git a/Signal/src/Loki/View Controllers/JoinPublicChatVC.swift b/Signal/src/Loki/View Controllers/JoinPublicChatVC.swift
index cbe948da8..1e20e8984 100644
--- a/Signal/src/Loki/View Controllers/JoinPublicChatVC.swift
+++ b/Signal/src/Loki/View Controllers/JoinPublicChatVC.swift
@@ -138,7 +138,7 @@ final class JoinPublicChatVC : BaseVC, UIPageViewControllerDataSource, UIPageVie
let displayName = profileManager.profileNameForRecipient(withID: userPublicKey)
let profilePictureURL = profileManager.profilePictureURL()
let profileKey = profileManager.localProfileKey().keyData
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
transaction.removeObject(forKey: "\(urlAsString).\(channelID)", inCollection: PublicChatAPI.lastMessageServerIDCollection)
transaction.removeObject(forKey: "\(urlAsString).\(channelID)", inCollection: PublicChatAPI.lastDeletionServerIDCollection)
}
diff --git a/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift b/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift
index 722901942..468d4fb24 100644
--- a/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift
+++ b/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift
@@ -178,7 +178,7 @@ final class NewClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelegat
ModalActivityIndicatorViewController.present(fromViewController: navigationController!, canCancel: false) { [weak self] _ in
FileServerAPI.getDeviceLinks(associatedWith: selectedContacts).then2 { _ -> Promise in
var promise: Promise!
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
promise = ClosedGroupsProtocol.createClosedGroup(name: name, members: selectedContacts, transaction: transaction)
}
return promise
diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m
index 1f4f5a1fb..69f6d070c 100644
--- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m
+++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m
@@ -1228,7 +1228,7 @@ typedef enum : NSUInteger {
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[thread addSessionRestoreDevice:thread.contactIdentifier transaction:transaction];
[LKSessionManagementProtocol startSessionResetInThread:thread transaction:transaction];
- } error:nil];
+ }];
[weakSelf updateSessionRestoreBanner];
});
}
@@ -2317,7 +2317,7 @@ typedef enum : NSUInteger {
contactThread.hasDismissedOffers = YES;
[contactThread saveWithTransaction:transaction];
[interaction removeWithTransaction:transaction];
- } error:nil];
+ }];
}];
[actionSheet addAction:blockAction];
@@ -2345,7 +2345,7 @@ typedef enum : NSUInteger {
contactThread.hasDismissedOffers = YES;
[contactThread saveWithTransaction:transaction];
[interaction removeWithTransaction:transaction];
- } error:nil];
+ }];
}
- (void)tappedAddToProfileWhitelistOfferMessage:(OWSContactOffersInteraction *)interaction
@@ -2363,7 +2363,7 @@ typedef enum : NSUInteger {
contactThread.hasDismissedOffers = YES;
[contactThread saveWithTransaction:transaction];
[interaction removeWithTransaction:transaction];
- } error:nil];
+ }];
}];
}
@@ -2546,13 +2546,13 @@ typedef enum : NSUInteger {
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *postSuccessTransaction) {
[message setQuotedMessageThumbnailAttachmentStream:attachmentStream];
[message saveWithTransaction:postSuccessTransaction];
- } error:nil];
+ }];
}
failure:^(NSError *error) {
OWSLogWarn(@"Failed to redownload thumbnail with error: %@", error);
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *postSuccessTransaction) {
[message touchWithTransaction:postSuccessTransaction];
- } error:nil];
+ }];
}];
}];
}
@@ -3682,7 +3682,7 @@ typedef enum : NSUInteger {
groupMetaMessage:TSGroupMetaMessageUpdate
expiresInSeconds:expiresInSeconds];
[message updateWithCustomMessage:updateGroupInfo transaction:transaction];
- } error:nil];
+ }];
[groupThread fireAvatarChangedNotification];
diff --git a/Signal/src/ViewControllers/MessageDetailViewController.swift b/Signal/src/ViewControllers/MessageDetailViewController.swift
index 34d934804..870b8f4b0 100644
--- a/Signal/src/ViewControllers/MessageDetailViewController.swift
+++ b/Signal/src/ViewControllers/MessageDetailViewController.swift
@@ -224,7 +224,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
let senderId = incomingMessage.authorId
let threadID = thread.uniqueId!
var senderName: String!
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
senderName = DisplayNameUtilities2.getDisplayName(for: senderId, inThreadWithID: threadID, using: transaction)
}
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_SENDER",
diff --git a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m
index 2005efbc6..07d633616 100644
--- a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m
+++ b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m
@@ -531,7 +531,7 @@ typedef void (^CustomLayoutBlock)(void);
recipientId:self.recipientId
isUserInitiatedChange:YES
transaction:transaction];
- } error:nil];
+ }];
[self dismissViewControllerAnimated:YES completion:nil];
}
diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m
index 8e5fc7957..476b5ce7a 100644
--- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m
+++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m
@@ -1107,7 +1107,7 @@ static CGRect oldframe;
thread:self.thread];
[self.messageSenderJobQueue addMessage:message transaction:transaction];
- } error:nil];
+ }];
}
}
@@ -1232,7 +1232,7 @@ static CGRect oldframe;
NSString *groupPublicKey = [LKGroupUtilities getDecodedGroupID:gThread.groupModel.groupId];
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[[LKClosedGroupsProtocol leaveGroupWithPublicKey:groupPublicKey transaction:transaction] retainUntilComplete];
- } error:nil];
+ }];
} else {
TSOutgoingMessage *message =
[TSOutgoingMessage outgoingMessageInThread:gThread groupMetaMessage:TSGroupMetaMessageQuit expiresInSeconds:0];
@@ -1240,7 +1240,7 @@ static CGRect oldframe;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.messageSenderJobQueue addMessage:message transaction:transaction];
[gThread leaveGroupWithTransaction:transaction];
- } error:nil];
+ }];
}
[self.navigationController popViewControllerAnimated:YES];
@@ -1459,7 +1459,7 @@ static CGRect oldframe;
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction * _Nonnull transaction) {
[self.thread updateWithMutedUntilDate:value transaction:transaction];
- } error:nil];
+ }];
[self updateTableContents];
}
@@ -1500,7 +1500,7 @@ static CGRect oldframe;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[thread addSessionRestoreDevice:thread.contactIdentifier transaction:transaction];
[LKSessionManagementProtocol startSessionResetInThread:thread transaction:transaction];
- } error:nil];
+ }];
[weakSelf.navigationController popViewControllerAnimated:YES];
});
}]];
@@ -1551,7 +1551,7 @@ static CGRect oldframe;
OWSLogDebug(@"picked color: %@", conversationColor.name);
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.thread updateConversationColorName:conversationColor.name transaction:transaction];
- } error:nil];
+ }];
[self.contactsManager.avatarCache removeAllImages];
[self updateTableContents];
diff --git a/Signal/src/environment/SignalApp.m b/Signal/src/environment/SignalApp.m
index 7a7287904..e0b3ab993 100644
--- a/Signal/src/environment/SignalApp.m
+++ b/Signal/src/environment/SignalApp.m
@@ -64,7 +64,7 @@ NS_ASSUME_NONNULL_BEGIN
__block TSThread *thread = nil;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
thread = [TSContactThread getOrCreateThreadWithContactId:recipientId transaction:transaction];
- } error:nil];
+ }];
[self presentConversationForThread:thread action:action animated:(BOOL)isAnimated];
}
diff --git a/Signal/src/util/Backup/OWSBackup.m b/Signal/src/util/Backup/OWSBackup.m
index 5fd3c932d..0a7fa76ae 100644
--- a/Signal/src/util/Backup/OWSBackup.m
+++ b/Signal/src/util/Backup/OWSBackup.m
@@ -870,7 +870,7 @@ NSError *OWSBackupErrorWithDescription(NSString *description)
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
// This should overwrite the attachment pointer with an attachment stream.
[stream saveWithTransaction:transaction];
- } error:nil];
+ }];
return [AnyPromise promiseWithValue:@(1)];
}
diff --git a/Signal/src/util/Backup/OWSBackupExportJob.m b/Signal/src/util/Backup/OWSBackupExportJob.m
index dfff21b97..42bac9bbc 100644
--- a/Signal/src/util/Backup/OWSBackupExportJob.m
+++ b/Signal/src/util/Backup/OWSBackupExportJob.m
@@ -866,7 +866,7 @@ NS_ASSUME_NONNULL_BEGIN
backupFragment.uncompressedDataLength = exportItem.uncompressedDataLength;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[backupFragment saveWithTransaction:transaction];
- } error:nil];
+ }];
OWSLogVerbose(@"saved attachment: %@ as %@",
attachmentExport.attachmentFilePath,
@@ -1110,7 +1110,7 @@ NS_ASSUME_NONNULL_BEGIN
[obsoleteRecordNames minusSet:activeRecordNames];
[transaction removeObjectsForKeys:obsoleteRecordNames.allObjects inCollection:[OWSBackupFragment collection]];
- } error:nil];
+ }];
}
- (AnyPromise *)cleanUpCloudWithActiveRecordNames:(NSSet *)activeRecordNames
diff --git a/Signal/src/util/Backup/OWSBackupImportJob.m b/Signal/src/util/Backup/OWSBackupImportJob.m
index 145ae74e7..22e89eabf 100644
--- a/Signal/src/util/Backup/OWSBackupImportJob.m
+++ b/Signal/src/util/Backup/OWSBackupImportJob.m
@@ -161,7 +161,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
for (OWSBackupFragment *item in allItems) {
[item saveWithTransaction:transaction];
}
- } error:nil];
+ }];
return [self downloadFilesFromCloud:blockingItems]
.thenInBackground(^{
@@ -428,7 +428,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
@"Indicates that the backup import data is being restored.")
progress:@(count / (CGFloat)self.attachmentsItems.count)];
}
- } error:nil];
+ }];
OWSLogError(@"enqueued lazy restore of %zd files.", count);
@@ -585,7 +585,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
}
}
}
- } error:nil];
+ }];
if (aborted) {
return [AnyPromise promiseWithValue:OWSBackupErrorWithDescription(@"Backup import failed.")];
diff --git a/Signal/src/util/OWSOrphanDataCleaner.m b/Signal/src/util/OWSOrphanDataCleaner.m
index afcf8069d..33dbd3934 100644
--- a/Signal/src/util/OWSOrphanDataCleaner.m
+++ b/Signal/src/util/OWSOrphanDataCleaner.m
@@ -533,7 +533,7 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
[transaction setDate:[NSDate new]
forKey:OWSOrphanDataCleaner_LastCleaningDateKey
inCollection:OWSOrphanDataCleaner_Collection];
- } error:nil];
+ }];
if (completion) {
completion();
@@ -675,7 +675,7 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
[attachmentStream removeWithTransaction:transaction];
}
OWSLogInfo(@"Deleted orphan attachments: %zu", attachmentsRemoved);
- } error:nil];
+ }];
if (shouldAbort) {
return nil;
diff --git a/Signal/src/util/Pastelog.m b/Signal/src/util/Pastelog.m
index 49ec63dd5..4a15cf545 100644
--- a/Signal/src/util/Pastelog.m
+++ b/Signal/src/util/Pastelog.m
@@ -598,14 +598,14 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
__block TSThread *thread = nil;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
thread = [TSContactThread getOrCreateThreadWithContactId:recipientId transaction:transaction];
- } error:nil];
+ }];
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[ThreadUtil enqueueMessageWithText:url.absoluteString
inThread:thread
quotedReplyModel:nil
linkPreviewDraft:nil
transaction:transaction];
- } error:nil];
+ }];
});
// Also copy to pasteboard.
@@ -630,7 +630,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
quotedReplyModel:nil
linkPreviewDraft:nil
transaction:transaction];
- } error:nil];
+ }];
} else {
[Pastelog showFailureAlertWithMessage:@"Could not find last thread."];
}
diff --git a/SignalMessaging/Loki/Migrations/LK002RemoveFriendRequests.swift b/SignalMessaging/Loki/Migrations/LK002RemoveFriendRequests.swift
index 1143ce9bb..ef40bc98b 100644
--- a/SignalMessaging/Loki/Migrations/LK002RemoveFriendRequests.swift
+++ b/SignalMessaging/Loki/Migrations/LK002RemoveFriendRequests.swift
@@ -13,7 +13,7 @@ public class LK002RemoveFriendRequests : OWSDatabaseMigration {
private func doMigrationAsync(completion: @escaping OWSDatabaseMigrationCompletion) {
DispatchQueue.global().async {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
var interactionIDsToRemove: [String] = []
transaction.enumerateRows(inCollection: TSInteraction.collection()) { key, object, _, _ in
if !(object is TSInteraction) {
diff --git a/SignalMessaging/ViewControllers/SelectThreadViewController.m b/SignalMessaging/ViewControllers/SelectThreadViewController.m
index 8c69e94a1..081999754 100644
--- a/SignalMessaging/ViewControllers/SelectThreadViewController.m
+++ b/SignalMessaging/ViewControllers/SelectThreadViewController.m
@@ -348,7 +348,7 @@ NS_ASSUME_NONNULL_BEGIN
__block TSThread *thread = nil;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
thread = [TSContactThread getOrCreateThreadWithContactId:signalAccount.recipientId transaction:transaction];
- } error:nil];
+ }];
OWSAssertDebug(thread);
[self.selectThreadViewDelegate threadWasSelected:thread];
diff --git a/SignalMessaging/Views/ContactCellView.m b/SignalMessaging/Views/ContactCellView.m
index be6053e5c..eaaff2644 100644
--- a/SignalMessaging/Views/ContactCellView.m
+++ b/SignalMessaging/Views/ContactCellView.m
@@ -231,7 +231,7 @@ const CGFloat kContactCellAvatarTextMargin = 12;
__block NSString *displayName = nil;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
displayName = [LKDisplayNameUtilities2 getDisplayNameForPublicKey:publicKey threadID:threadID transaction:transaction];
- } error:nil];
+ }];
self.nameLabel.text = displayName;
[self.nameLabel setNeedsLayout];
}
diff --git a/SignalMessaging/contacts/OWSContactsManager.m b/SignalMessaging/contacts/OWSContactsManager.m
index bea437087..09c1d39e3 100644
--- a/SignalMessaging/contacts/OWSContactsManager.m
+++ b/SignalMessaging/contacts/OWSContactsManager.m
@@ -354,7 +354,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
forKey:OWSContactsManagerKeyNextFullIntersectionDate
inCollection:OWSContactsManagerCollection];
}
- } error:nil];
+ }];
});
}
@@ -553,7 +553,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
[signalAccounts sortUsingComparator:self.signalAccountComparator];
}
}
- } error:nil];
+ }];
dispatch_async(dispatch_get_main_queue(), ^{
[self updateSignalAccounts:signalAccounts];
diff --git a/SignalMessaging/contacts/OWSSyncManager.m b/SignalMessaging/contacts/OWSSyncManager.m
index d76fed195..618ec69be 100644
--- a/SignalMessaging/contacts/OWSSyncManager.m
+++ b/SignalMessaging/contacts/OWSSyncManager.m
@@ -253,7 +253,7 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.messageSenderJobQueue addMessage:syncConfigurationMessage transaction:transaction];
- } error:nil];
+ }];
}
#pragma mark - Local Sync
@@ -306,7 +306,7 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
__block AnyPromise *promise;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
promise = [LKSyncMessagesProtocol syncClosedGroup:thread transaction:transaction];
- } error:nil];
+ }];
return promise;
} else {
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] initWithGroupThread:thread];
diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m
index 5be0d1fac..8d0ed2589 100644
--- a/SignalMessaging/environment/OWSSounds.m
+++ b/SignalMessaging/environment/OWSSounds.m
@@ -294,7 +294,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self setGlobalNotificationSound:sound transaction:transaction];
- } error:nil];
+ }];
}
+ (void)setGlobalNotificationSound:(OWSSound)sound transaction:(YapDatabaseReadWriteTransaction *)transaction
diff --git a/SignalMessaging/environment/VersionMigrations.m b/SignalMessaging/environment/VersionMigrations.m
index 70d136897..d0f7287b6 100644
--- a/SignalMessaging/environment/VersionMigrations.m
+++ b/SignalMessaging/environment/VersionMigrations.m
@@ -153,7 +153,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSLogInfo(@"Successfully removed bloom filter cache.");
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[transaction removeAllObjectsInCollection:@"TSRecipient"];
- } error:nil];
+ }];
OWSLogInfo(@"Removed all TSRecipient records - will be replaced by SignalRecipients at next address sync.");
} else {
OWSLogError(@"Failed to remove bloom filter cache with error: %@", deleteError.localizedDescription);
diff --git a/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m b/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m
index e1ec293e8..c3622fa07 100644
--- a/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m
+++ b/SignalMessaging/environment/migrations/OWSDatabaseMigrationRunner.m
@@ -67,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSLogInfo(@"Culling unknown migration: %@", unknownMigrationId);
[transaction removeObjectForKey:unknownMigrationId inCollection:OWSDatabaseMigration.collection];
}
- } error:nil];
+ }];
}
// Run migrations serially to:
diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m
index 006126dea..c64840fdc 100644
--- a/SignalMessaging/profiles/OWSProfileManager.m
+++ b/SignalMessaging/profiles/OWSProfileManager.m
@@ -183,7 +183,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
__block OWSUserProfile *userProfile;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
userProfile = [self getLocalUserProfileWithTransaction:transaction];
- } error:nil];
+ }];
return userProfile;
}
@@ -717,7 +717,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
[transaction removeObjectForKey:groupIdKey
inCollection:kOWSProfileManager_GroupWhitelistCollection];
}
- } error:nil];
+ }];
return @(1);
});
@@ -1057,7 +1057,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
result = [self profileNameForRecipientWithID:recipientID transaction:transaction];
- } error:nil];
+ }];
NSString *shortID = [recipientID substringWithRange:NSMakeRange(recipientID.length - 8, 8)];
NSString *suffix = [NSString stringWithFormat:@" (...%@)", shortID];
@@ -1480,7 +1480,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.messageSenderJobQueue addMessage:message transaction:transaction];
- } error:nil];
+ }];
}
#pragma mark - Notifications
diff --git a/SignalMessaging/profiles/OWSUserProfile.m b/SignalMessaging/profiles/OWSUserProfile.m
index 5fd1311bb..c5280bfaa 100644
--- a/SignalMessaging/profiles/OWSUserProfile.m
+++ b/SignalMessaging/profiles/OWSUserProfile.m
@@ -66,7 +66,7 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
userProfile = [OWSUserProfile getOrBuildUserProfileForRecipientId:recipientId transaction:transaction];
- } error:nil];
+ }];
return userProfile;
}
@@ -199,7 +199,7 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self applyChanges:changeBlock functionName:functionName transaction:transaction completion:completion];
- } error:nil];
+ }];
}
- (void)applyChanges:(void (^)(id))changeBlock
@@ -381,7 +381,7 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self updateWithProfileKey:profileKey transaction:transaction completion:completion];
- } error:nil];
+ }];
}
- (void)updateWithProfileKey:(OWSAES256Key *)profileKey
diff --git a/SignalMessaging/utils/OWSPreferences.m b/SignalMessaging/utils/OWSPreferences.m
index d8622f870..3a128f556 100644
--- a/SignalMessaging/utils/OWSPreferences.m
+++ b/SignalMessaging/utils/OWSPreferences.m
@@ -90,7 +90,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self setValueForKey:key toValue:value transaction:transaction];
- } error:nil];
+ }];
}
- (void)setValueForKey:(NSString *)key
diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m
index b561dba73..9c3557733 100644
--- a/SignalMessaging/utils/ThreadUtil.m
+++ b/SignalMessaging/utils/ThreadUtil.m
@@ -712,7 +712,7 @@ typedef void (^BuildOutgoingMessageCompletionBlock)(TSOutgoingMessage *savedMess
} @catch (NSException *exception) {
// Do nothing
}
- } error:nil];
+ }];
[TSAttachmentStream deleteAttachments];
}
diff --git a/SignalServiceKit/src/Account/TSAccountManager.m b/SignalServiceKit/src/Account/TSAccountManager.m
index fc516ab00..c5b014ad8 100644
--- a/SignalServiceKit/src/Account/TSAccountManager.m
+++ b/SignalServiceKit/src/Account/TSAccountManager.m
@@ -253,7 +253,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
__block uint32_t result;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
result = [self getOrGenerateRegistrationId:transaction];
- } error:nil];
+ }];
return result;
}
@@ -527,7 +527,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
[transaction setObject:authToken
forKey:TSAccountManager_ServerAuthToken
inCollection:TSAccountManager_UserAccountCollection];
- } error:nil];
+ }];
}
+ (void)unregisterTextSecureWithSuccess:(void (^)(void))success failure:(void (^)(NSError *error))failureBlock
@@ -631,7 +631,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
[transaction setObject:localNumber
forKey:TSAccountManager_ReregisteringPhoneNumberKey
inCollection:TSAccountManager_UserAccountCollection];
- } error:nil];
+ }];
[self postRegistrationStateDidChangeNotification];
@@ -733,7 +733,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
[transaction removeObjectForKey:TSAccountManager_NeedsAccountAttributesUpdateKey
inCollection:TSAccountManager_UserAccountCollection];
}
- } error:nil];
+ }];
});
return promise;
}
diff --git a/SignalServiceKit/src/Contacts/ContactsUpdater.m b/SignalServiceKit/src/Contacts/ContactsUpdater.m
index 93871eebe..22ee254a4 100644
--- a/SignalServiceKit/src/Contacts/ContactsUpdater.m
+++ b/SignalServiceKit/src/Contacts/ContactsUpdater.m
@@ -106,7 +106,7 @@ NS_ASSUME_NONNULL_BEGIN
[SignalRecipient markRecipientAsUnregistered:recipientId transaction:transaction];
}
}
- } error:nil];
+ }];
dispatch_async(dispatch_get_main_queue(), ^{
success([recipients copy]);
diff --git a/SignalServiceKit/src/Contacts/Threads/TSContactThread.m b/SignalServiceKit/src/Contacts/Threads/TSContactThread.m
index d01ca8797..3361fe675 100644
--- a/SignalServiceKit/src/Contacts/Threads/TSContactThread.m
+++ b/SignalServiceKit/src/Contacts/Threads/TSContactThread.m
@@ -55,7 +55,7 @@ NSString *const TSContactThreadPrefix = @"c";
__block TSContactThread *thread;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
thread = [self getOrCreateThreadWithContactId:contactId transaction:transaction];
- } error:nil];
+ }];
return thread;
}
diff --git a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m
index 30934e5de..081f8cdb2 100644
--- a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m
+++ b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m
@@ -97,7 +97,7 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
thread = [self getOrCreateThreadWithGroupId:groupId groupType:groupType transaction:transaction];
- } error:nil];
+ }];
return thread;
}
@@ -128,7 +128,7 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
thread = [self getOrCreateThreadWithGroupModel:groupModel transaction:transaction];
- } error:nil];
+ }];
return thread;
}
@@ -264,7 +264,7 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self leaveGroupWithTransaction:transaction];
- } error:nil];
+ }];
}
- (void)leaveGroupWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
@@ -294,7 +294,7 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self updateAvatarWithAttachmentStream:attachmentStream transaction:transaction];
- } error:nil];
+ }];
}
- (void)updateAvatarWithAttachmentStream:(TSAttachmentStream *)attachmentStream
diff --git a/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m b/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m
index 9977c9723..e0a903a80 100644
--- a/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m
+++ b/SignalServiceKit/src/Devices/OWSRecordTranscriptJob.m
@@ -145,7 +145,7 @@ NS_ASSUME_NONNULL_BEGIN
if (serverID != 0) {
[OWSPrimaryStorage.sharedManager setIDForMessageWithServerID:serverID to:outgoingMessage.uniqueId in:transaction];
}
- } error:nil];
+ }];
}
failure:^(NSError *error) {
OWSLogWarn(@"failed to fetch thumbnail for transcript: %lu with error: %@",
diff --git a/SignalServiceKit/src/Loki/API/DotNetAPI.swift b/SignalServiceKit/src/Loki/API/DotNetAPI.swift
index ec59ced68..7fc906bfd 100644
--- a/SignalServiceKit/src/Loki/API/DotNetAPI.swift
+++ b/SignalServiceKit/src/Loki/API/DotNetAPI.swift
@@ -31,7 +31,7 @@ public class DotNetAPI : NSObject {
return Promise.value(token)
} else {
return requestNewAuthToken(for: server).then2 { submitAuthToken($0, for: server) }.map2 { token in
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
setAuthToken(for: server, to: token, in: transaction)
}
return token
@@ -52,7 +52,7 @@ public class DotNetAPI : NSObject {
}
public static func removeAuthToken(for server: String) {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
transaction.removeObject(forKey: server, inCollection: authTokenCollection)
}
}
diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift
index 3d48ec977..66432ef61 100644
--- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift
+++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift
@@ -134,7 +134,7 @@ public enum OnionRequestAPI {
}
}.map2 { paths in
OnionRequestAPI.paths = paths + reusablePaths
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
print("[Loki] Persisting onion request paths to database.")
Storage.setOnionRequestPaths(paths, using: transaction)
}
@@ -214,7 +214,7 @@ public enum OnionRequestAPI {
oldPaths.remove(at: pathIndex)
let newPaths = oldPaths + [ path ]
paths = newPaths
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
print("[Loki] Persisting onion request paths to database.")
Storage.setOnionRequestPaths(newPaths, using: transaction)
}
@@ -226,7 +226,7 @@ public enum OnionRequestAPI {
guard let pathIndex = paths.firstIndex(of: path) else { return }
paths.remove(at: pathIndex)
OnionRequestAPI.paths = paths
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
if !paths.isEmpty {
print("[Loki] Persisting onion request paths to database.")
Storage.setOnionRequestPaths(paths, using: transaction)
diff --git a/SignalServiceKit/src/Loki/API/Open Groups/PublicChatAPI.swift b/SignalServiceKit/src/Loki/API/Open Groups/PublicChatAPI.swift
index 64730ad7d..1661414bc 100644
--- a/SignalServiceKit/src/Loki/API/Open Groups/PublicChatAPI.swift
+++ b/SignalServiceKit/src/Loki/API/Open Groups/PublicChatAPI.swift
@@ -63,7 +63,7 @@ public final class PublicChatAPI : DotNetAPI {
}
public static func clearCaches(for channel: UInt64, on server: String) {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
removeLastMessageServerID(for: channel, on: server, using: transaction)
removeLastDeletionServerID(for: channel, on: server, using: transaction)
Storage.removeOpenGroupPublicKey(for: server, using: transaction)
@@ -79,7 +79,7 @@ public final class PublicChatAPI : DotNetAPI {
let url = URL(string: server)!
let request = TSRequest(url: url)
return OnionRequestAPI.sendOnionRequest(request, to: server, using: publicKey, isJSONRequired: false).map(on: DispatchQueue.global(qos: .default)) { _ -> String in
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
Storage.setOpenGroupPublicKey(for: server, to: publicKey, using: transaction)
}
return publicKey
@@ -132,7 +132,7 @@ public final class PublicChatAPI : DotNetAPI {
}
let lastMessageServerID = getLastMessageServerID(for: channel, on: server)
if serverID > (lastMessageServerID ?? 0) {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
setLastMessageServerID(for: channel, on: server, to: serverID, using: transaction)
}
}
@@ -255,7 +255,7 @@ public final class PublicChatAPI : DotNetAPI {
}
let lastDeletionServerID = getLastDeletionServerID(for: channel, on: server)
if serverID > (lastDeletionServerID ?? 0) {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
setLastDeletionServerID(for: channel, on: server, to: serverID, using: transaction)
}
}
@@ -305,7 +305,7 @@ public final class PublicChatAPI : DotNetAPI {
print("[Loki] Couldn't parse display names for users: \(publicKeys) from: \(json).")
throw DotNetAPIError.parsingFailed
}
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
data.forEach { data in
guard let user = data["user"] as? JSON, let hexEncodedPublicKey = user["username"] as? String, let rawDisplayName = user["name"] as? String else { return }
let endIndex = hexEncodedPublicKey.endIndex
@@ -372,7 +372,7 @@ public final class PublicChatAPI : DotNetAPI {
static func updateProfileIfNeeded(for channel: UInt64, on server: String, from info: PublicChatInfo) {
let storage = OWSPrimaryStorage.shared()
let publicChatID = "\(server).\(channel)"
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
// Update user count
storage.setUserCount(info.memberCount, forPublicChatWithID: publicChatID, in: transaction)
let groupThread = TSGroupThread.getOrCreateThread(withGroupId: publicChatID.data(using: .utf8)!, groupType: .openGroup, transaction: transaction)
@@ -425,7 +425,7 @@ public final class PublicChatAPI : DotNetAPI {
throw DotNetAPIError.parsingFailed
}
let storage = OWSPrimaryStorage.shared()
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
storage.setUserCount(memberCount, forPublicChatWithID: "\(server).\(channel)", in: transaction)
}
let publicChatInfo = PublicChatInfo(displayName: displayName, profilePictureURL: profilePictureURL, memberCount: memberCount)
diff --git a/SignalServiceKit/src/Loki/API/Open Groups/PublicChatPoller.swift b/SignalServiceKit/src/Loki/API/Open Groups/PublicChatPoller.swift
index b3e3bce27..7ec06348f 100644
--- a/SignalServiceKit/src/Loki/API/Open Groups/PublicChatPoller.swift
+++ b/SignalServiceKit/src/Loki/API/Open Groups/PublicChatPoller.swift
@@ -175,7 +175,7 @@ public final class PublicChatPoller : NSObject {
envelope.setSourceDevice(OWSDevicePrimaryDeviceId)
envelope.setContent(try! content.build().serializedData())
envelope.setServerTimestamp(message.serverTimestamp)
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
transaction.setObject(senderDisplayName, forKey: senderPublicKey, inCollection: publicChat.id)
let messageServerID = message.serverID
SSKEnvironment.shared.messageManager.throws_processEnvelope(try! envelope.build(), plaintextData: try! content.build().serializedData(), wasReceivedByUD: false, transaction: transaction, serverID: messageServerID ?? 0)
@@ -229,7 +229,7 @@ public final class PublicChatPoller : NSObject {
private func pollForDeletedMessages() {
let publicChat = self.publicChat
let _ = PublicChatAPI.getDeletedMessageServerIDs(for: publicChat.channel, on: publicChat.server).done(on: DispatchQueue.global(qos: .default)) { deletedMessageServerIDs in
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
let deletedMessageIDs = deletedMessageServerIDs.compactMap { OWSPrimaryStorage.shared().getIDForMessage(withServerID: UInt($0), in: transaction) }
deletedMessageIDs.forEach { messageID in
TSMessage.fetch(uniqueId: messageID)?.remove(with: transaction)
diff --git a/SignalServiceKit/src/Loki/API/Open Groups/To Do/PublicChatManager.swift b/SignalServiceKit/src/Loki/API/Open Groups/To Do/PublicChatManager.swift
index 1fe3e6fc6..1814c6646 100644
--- a/SignalServiceKit/src/Loki/API/Open Groups/To Do/PublicChatManager.swift
+++ b/SignalServiceKit/src/Loki/API/Open Groups/To Do/PublicChatManager.swift
@@ -69,7 +69,7 @@ public final class PublicChatManager : NSObject {
let model = TSGroupModel(title: chat.displayName, memberIds: [userHexEncodedPublicKey!, chat.server], image: nil, groupId: LKGroupUtilities.getEncodedOpenGroupIDAsData(chat.id), groupType: .openGroup, adminIds: [])
// Store the group chat mapping
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
let thread = TSGroupThread.getOrCreateThread(with: model, transaction: transaction)
// Save the group chat
@@ -116,7 +116,7 @@ public final class PublicChatManager : NSObject {
}
// Remove the chat from the db
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
LokiDatabaseUtilities.removePublicChat(for: threadId, in: transaction)
}
diff --git a/SignalServiceKit/src/Loki/API/SnodeAPI.swift b/SignalServiceKit/src/Loki/API/SnodeAPI.swift
index 1df447aeb..aa365a499 100644
--- a/SignalServiceKit/src/Loki/API/SnodeAPI.swift
+++ b/SignalServiceKit/src/Loki/API/SnodeAPI.swift
@@ -97,7 +97,7 @@ public final class SnodeAPI : NSObject {
}
}.done2 { snode in
seal.fulfill(snode)
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
print("[Loki] Persisting snode pool to database.")
storage.setSnodePool(SnodeAPI.snodePool, in: transaction)
}
@@ -132,7 +132,7 @@ public final class SnodeAPI : NSObject {
}.map2 { rawSnodes in
let swarm = parseSnodes(from: rawSnodes)
swarmCache[publicKey] = swarm
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
storage.setSwarm(swarm, for: publicKey, in: transaction)
}
return swarm
@@ -147,14 +147,14 @@ public final class SnodeAPI : NSObject {
internal static func dropSnodeFromSnodePool(_ snode: Snode) {
SnodeAPI.snodePool.remove(snode)
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
storage.dropSnodeFromSnodePool(snode, in: transaction)
}
}
@objc public static func clearSnodePool() {
snodePool.removeAll()
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
storage.clearSnodePool(in: transaction)
}
}
@@ -164,7 +164,7 @@ public final class SnodeAPI : NSObject {
if var swarm = swarm, let index = swarm.firstIndex(of: snode) {
swarm.remove(at: index)
SnodeAPI.swarmCache[publicKey] = swarm
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
storage.setSwarm(swarm, for: publicKey, in: transaction)
}
}
@@ -172,7 +172,7 @@ public final class SnodeAPI : NSObject {
// MARK: Receiving
internal static func getRawMessages(from snode: Snode, associatedWith publicKey: String) -> RawResponsePromise {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
Storage.pruneLastMessageHashInfoIfExpired(for: snode, associatedWith: publicKey, using: transaction)
}
let lastHash = Storage.getLastMessageHash(for: snode, associatedWith: publicKey) ?? ""
@@ -257,7 +257,7 @@ public final class SnodeAPI : NSObject {
private static func updateLastMessageHashValueIfPossible(for snode: Snode, associatedWith publicKey: String, from rawMessages: [JSON]) {
if let lastMessage = rawMessages.last, let lastHash = lastMessage["hash"] as? String, let expirationDate = lastMessage["expiration"] as? UInt64 {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
Storage.setLastMessageHashInfo(for: snode, associatedWith: publicKey, to: [ "hash" : lastHash, "expirationDate" : NSNumber(value: expirationDate) ], using: transaction)
}
} else if (!rawMessages.isEmpty) {
@@ -274,7 +274,7 @@ public final class SnodeAPI : NSObject {
}
let isDuplicate = receivedMessages.contains(hash)
receivedMessages.insert(hash)
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
Storage.setReceivedMessages(to: receivedMessages, for: publicKey, using: transaction)
}
return !isDuplicate
diff --git a/SignalServiceKit/src/Loki/Database/Storage.swift b/SignalServiceKit/src/Loki/Database/Storage.swift
index 1138fcb33..add543757 100644
--- a/SignalServiceKit/src/Loki/Database/Storage.swift
+++ b/SignalServiceKit/src/Loki/Database/Storage.swift
@@ -69,8 +69,8 @@ public final class Storage : NSObject {
/// Blocks the calling thread until the write has finished.
@discardableResult
- @objc(writeSyncWithBlock:error:)
- public static func writeSync(with block: @escaping (YapDatabaseReadWriteTransaction) -> Void) throws {
- try write(with: block, completion: { }).wait()
+ @objc(writeSyncWithBlock:)
+ public static func writeSync(with block: @escaping (YapDatabaseReadWriteTransaction) -> Void) {
+ try! write(with: block, completion: { }).wait() // The promise returned by write(with:completion:) never rejects
}
}
diff --git a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift
index ef9d5dd3e..0d62b1750 100644
--- a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift
+++ b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift
@@ -131,7 +131,7 @@ public final class ClosedGroupsProtocol : NSObject {
}
when(resolved: promises).done2 { _ in seal.fulfill(()) }.catch2 { seal.reject($0) }
promise.done {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
let allOldRatchets = Storage.getAllClosedGroupRatchets(for: groupPublicKey)
for (senderPublicKey, oldRatchet) in allOldRatchets {
let collection = Storage.ClosedGroupRatchetCollectionType.old
diff --git a/SignalServiceKit/src/Loki/Protocol/Shelved/Sync Messages/SyncMessagesProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Shelved/Sync Messages/SyncMessagesProtocol.swift
index 5a8694de5..00e9096c4 100644
--- a/SignalServiceKit/src/Loki/Protocol/Shelved/Sync Messages/SyncMessagesProtocol.swift
+++ b/SignalServiceKit/src/Loki/Protocol/Shelved/Sync Messages/SyncMessagesProtocol.swift
@@ -28,7 +28,7 @@ public final class SyncMessagesProtocol : NSObject {
// MARK: - Sending
@objc public static func syncProfile() {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
let userPublicKey = getUserHexEncodedPublicKey()
let userLinkedDevices = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userPublicKey, in: transaction)
for device in userLinkedDevices {
diff --git a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m
index f55716b41..f0471f14d 100644
--- a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m
+++ b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.m
@@ -292,7 +292,7 @@ typedef void (^AttachmentDownloadFailure)(NSError *error);
if (job.message) {
[job.message touchWithTransaction:transaction];
}
- } error:nil];
+ }];
[self retrieveAttachmentForJob:job
success:^(TSAttachmentStream *attachmentStream) {
@@ -304,7 +304,7 @@ typedef void (^AttachmentDownloadFailure)(NSError *error);
if (job.message) {
[job.message touchWithTransaction:transaction];
}
- } error:nil];
+ }];
job.success(attachmentStream);
@@ -325,7 +325,7 @@ typedef void (^AttachmentDownloadFailure)(NSError *error);
if (job.message) {
[job.message touchWithTransaction:transaction];
}
- } error:nil];
+ }];
@synchronized(self) {
[self.downloadingJobMap removeObjectForKey:job.attachmentPointer.uniqueId];
diff --git a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m
index 896cdf947..db6f12b91 100644
--- a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m
+++ b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m
@@ -674,7 +674,7 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self updateWithCustomMessage:customMessage transaction:transaction];
- } error:nil];
+ }];
}
- (void)saveIsCalculatingProofOfWork:(BOOL)isCalculatingPoW withTransaction:(YapDatabaseReadWriteTransaction *)transaction
diff --git a/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m b/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m
index 067763d21..c078ec2ed 100644
--- a/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m
+++ b/SignalServiceKit/src/Messages/OWSBatchMessageProcessor.m
@@ -171,7 +171,7 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[transaction removeObjectsForKeys:uniqueIds inCollection:[OWSMessageContentJob collection]];
- } error:nil];
+ }];
}
+ (YapDatabaseView *)databaseExtension
@@ -456,7 +456,7 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
break;
}
}
- } error:nil];
+ }];
return processedJobs;
}
diff --git a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m
index d3c0794f6..2e048ac13 100644
--- a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m
+++ b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m
@@ -140,7 +140,7 @@ void AssertIsOnDisappearingMessagesQueue()
expirationCount++;
}
transaction:transaction];
- } error:nil];
+ }];
OWSLogDebug(@"Removed %lu expired messages", (unsigned long)expirationCount);
@@ -269,7 +269,7 @@ void AssertIsOnDisappearingMessagesQueue()
// of messages across timer changes which could cause a disappearing message's timer to never be started.
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self cleanupMessagesWhichFailedToStartExpiringWithTransaction:transaction];
- } error:nil];
+ }];
[self runLoop];
});
diff --git a/SignalServiceKit/src/Messages/OWSFailedAttachmentDownloadsJob.m b/SignalServiceKit/src/Messages/OWSFailedAttachmentDownloadsJob.m
index 202ee51a6..f4d2a092d 100644
--- a/SignalServiceKit/src/Messages/OWSFailedAttachmentDownloadsJob.m
+++ b/SignalServiceKit/src/Messages/OWSFailedAttachmentDownloadsJob.m
@@ -88,7 +88,7 @@ static NSString *const OWSFailedAttachmentDownloadsJobAttachmentStateIndex = @"i
}
}
transaction:transaction];
- } error:nil];
+ }];
OWSLogDebug(@"Marked %u attachments as unsent", count);
}
diff --git a/SignalServiceKit/src/Messages/OWSFailedMessagesJob.m b/SignalServiceKit/src/Messages/OWSFailedMessagesJob.m
index be2e799d9..e851564bf 100644
--- a/SignalServiceKit/src/Messages/OWSFailedMessagesJob.m
+++ b/SignalServiceKit/src/Messages/OWSFailedMessagesJob.m
@@ -96,7 +96,7 @@ static NSString *const OWSFailedMessagesJobMessageStateIndex = @"index_outoing_m
count++;
}
transaction:transaction];
- } error:nil];
+ }];
OWSLogDebug(@"Marked %u messages as unsent", count);
}
diff --git a/SignalServiceKit/src/Messages/OWSIdentityManager.m b/SignalServiceKit/src/Messages/OWSIdentityManager.m
index 463ae79a9..09c516b9d 100644
--- a/SignalServiceKit/src/Messages/OWSIdentityManager.m
+++ b/SignalServiceKit/src/Messages/OWSIdentityManager.m
@@ -210,7 +210,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
__block BOOL result;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
result = [self saveRemoteIdentity:identityKey recipientId:recipientId protocolContext:transaction];
- } error:nil];
+ }];
return result;
}
@@ -302,7 +302,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
recipientId:recipientId
isUserInitiatedChange:isUserInitiatedChange
transaction:transaction];
- } error:nil];
+ }];
}
- (void)setVerificationState:(OWSVerificationState)verificationState
@@ -668,7 +668,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self clearSyncMessageForRecipientId:message.verificationForRecipientId
transaction:transaction];
- } error:nil];
+ }];
}
failure:^(NSError *error) {
OWSLogError(@"Failed to send verification state sync message with error: %@", error);
@@ -682,7 +682,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
// Otherwise this will fail forever.
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self clearSyncMessageForRecipientId:message.verificationForRecipientId transaction:transaction];
- } error:nil];
+ }];
}
}];
}
diff --git a/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m b/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m
index de35ef4a6..556c5fe73 100644
--- a/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m
+++ b/SignalServiceKit/src/Messages/OWSIncompleteCallsJob.m
@@ -107,7 +107,7 @@ static NSString *const OWSIncompleteCallsJobCallTypeIndex = @"index_calls_on_cal
count++;
}
transaction:transaction];
- } error:nil];
+ }];
OWSLogInfo(@"Marked %u calls as missed", count);
}
diff --git a/SignalServiceKit/src/Messages/OWSMessageDecrypter.m b/SignalServiceKit/src/Messages/OWSMessageDecrypter.m
index 7615e10fb..554d28a76 100644
--- a/SignalServiceKit/src/Messages/OWSMessageDecrypter.m
+++ b/SignalServiceKit/src/Messages/OWSMessageDecrypter.m
@@ -261,7 +261,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
sourceDevice:envelope.sourceDevice
isUDMessage:NO];
successBlock(result, transaction);
- } error:nil];
+ }];
// Return to avoid double-acknowledging.
return;
}
@@ -284,7 +284,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
sourceDevice:OWSDevicePrimaryDeviceId
isUDMessage:NO];
successBlock(result, transaction);
- } error:nil];
+ }];
return;
}
case SSKProtoEnvelopeTypeUnidentifiedSender: {
@@ -315,7 +315,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
[SSKEnvironment.shared.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
transaction:transaction];
- } error:nil];
+ }];
}
failureBlock();
@@ -667,7 +667,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
[contactThread saveWithTransaction:transaction];
}
}
- } error:nil];
+ }];
}
- (void)notifyUserForErrorMessage:(TSErrorMessage *)errorMessage
diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m
index 040dca1cc..713d999f8 100644
--- a/SignalServiceKit/src/Messages/OWSMessageManager.m
+++ b/SignalServiceKit/src/Messages/OWSMessageManager.m
@@ -931,7 +931,7 @@ NS_ASSUME_NONNULL_BEGIN
[groupThread updateAvatarWithAttachmentStream:attachmentStream
transaction:transaction];
- } error:nil];
+ }];
}
transaction:transaction
];
@@ -1607,7 +1607,7 @@ NS_ASSUME_NONNULL_BEGIN
// since the attachment might be a contact avatar, etc.
[incomingMessage touchWithTransaction:transaction];
}
- } error:nil];
+ }];
}
failure:^(NSError *error) {
OWSLogWarn(@"Failed to download attachment for message: %lu with error: %@.",
diff --git a/SignalServiceKit/src/Messages/OWSMessageReceiver.m b/SignalServiceKit/src/Messages/OWSMessageReceiver.m
index 0637abd2d..0852dd03f 100644
--- a/SignalServiceKit/src/Messages/OWSMessageReceiver.m
+++ b/SignalServiceKit/src/Messages/OWSMessageReceiver.m
@@ -140,14 +140,14 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
OWSMessageDecryptJob *job = [[OWSMessageDecryptJob alloc] initWithEnvelopeData:envelopeData];
[job saveWithTransaction:transaction];
- } error:nil];
+ }];
}
- (void)removeJobWithId:(NSString *)uniqueId
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[transaction removeObjectForKey:uniqueId inCollection:[OWSMessageDecryptJob collection]];
- } error:nil];
+ }];
}
+ (YapDatabaseView *)databaseExtension
@@ -380,7 +380,7 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
[SSKEnvironment.shared.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
transaction:transaction];
- } error:nil];
+ }];
dispatch_async(self.serialQueue, ^{
completion(NO);
diff --git a/SignalServiceKit/src/Messages/OWSMessageSender.m b/SignalServiceKit/src/Messages/OWSMessageSender.m
index 146e71eda..04c0b10b1 100644
--- a/SignalServiceKit/src/Messages/OWSMessageSender.m
+++ b/SignalServiceKit/src/Messages/OWSMessageSender.m
@@ -380,7 +380,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
if (message.allAttachmentIds.count > 0) {
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[allAttachmentIds addObjectsFromArray:[OutgoingMessagePreparer prepareMessageForSending:message transaction:transaction]];
- } error:nil];
+ }];
}
NSOperationQueue *sendingQueue = [self sendingQueueForMessage:message];
@@ -710,7 +710,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
for (NSString *recipientId in obsoleteRecipientIds) {
[message updateWithSkippedRecipient:recipientId transaction:transaction];
}
- } error:nil];
+ }];
}
if (recipientIds.count < 1) {
@@ -1065,7 +1065,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[message saveOpenGroupServerMessageID:groupMessage.serverID in:transaction];
[self.primaryStorage setIDForMessageWithServerID:groupMessage.serverID to:message.uniqueId in:transaction];
- } error:nil];
+ }];
[self messageSendDidSucceed:messageSend deviceMessages:deviceMessages wasSentByUD:messageSend.isUDSend wasSentByWebsocket:false];
})
.catchOn(OWSDispatch.sendingQueue, ^(NSError *error) {
@@ -1111,7 +1111,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
// Update the PoW calculation status
[message saveIsCalculatingProofOfWork:YES withTransaction:transaction];
}
- } error:nil];
+ }];
// Convenience
void (^handleError)(NSError *error) = ^(NSError *error) {
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
@@ -1119,7 +1119,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
// Update the PoW calculation status
[message saveIsCalculatingProofOfWork:NO withTransaction:transaction];
}
- } error:nil];
+ }];
// Handle the error
failedMessageSend(error);
};
@@ -1189,7 +1189,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
// If we've just delivered a message to a user, we know they
// have a valid Signal account.
[SignalRecipient markRecipientAsRegisteredAndGet:recipient.recipientId transaction:transaction];
- } error:nil];
+ }];
messageSend.success();
});
@@ -1266,7 +1266,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
for (NSString *recipientId in message.sendingRecipientIds) {
[message updateWithReadRecipientId:recipientId readTimestamp:message.timestamp transaction:transaction];
}
- } error:nil];
+ }];
}
successParam();
@@ -1276,7 +1276,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[[OWSDisappearingMessagesJob sharedJob] startAnyExpirationForMessage:message
expirationStartedAt:[NSDate ows_millisecondTimeStamp]
transaction:transaction];
- } error:nil];
+ }];
if (!message.shouldSyncTranscript) {
return success();
@@ -1294,7 +1294,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
success:^{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[message updateWithHasSyncedTranscript:YES transaction:transaction];
- } error:nil];
+ }];
success();
}
@@ -1328,7 +1328,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
__block SignalRecipient *recipient;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
recipient = [SignalRecipient markRecipientAsRegisteredAndGet:recipientId transaction:transaction];
- } error:nil];
+ }];
SMKSenderCertificate *senderCertificate = [self.udManager getSenderCertificate];
OWSUDAccess *recipientUDAccess = nil;
@@ -1393,7 +1393,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
__block BOOL isSessionRequired;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
isSessionRequired = [LKSessionManagementProtocol isSessionRequiredForMessage:messageSend.message recipientID:recipientID transaction:transaction];
- } error:nil];
+ }];
if (isSessionRequired) {
BOOL hasSession = [self throws_ensureRecipientHasSessionForMessageSend:messageSend recipientID:recipientID deviceId:@(OWSDevicePrimaryDeviceId)];
@@ -1416,7 +1416,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
} @catch (NSException *exception) {
encryptionException = exception;
}
- } error:nil];
+ }];
if (encryptionException) {
OWSLogInfo(@"Exception during encryption: %@.", encryptionException);
@@ -1434,7 +1434,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[recipient updateRegisteredRecipientWithDevicesToAdd:nil
devicesToRemove:@[ @(OWSDevicePrimaryDeviceId) ]
transaction:transaction];
- } error:nil];
+ }];
} else {
@throw exception;
}
@@ -1465,7 +1465,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
__block BOOL hasSession;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
hasSession = [storage containsSession:recipientID deviceId:[deviceId intValue] protocolContext:transaction];
- } error:nil];
+ }];
if (hasSession) { return YES; }
TSOutgoingMessage *message = messageSend.message;
@@ -1491,7 +1491,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
} @catch (NSException *caughtException) {
exception = caughtException;
}
- } error:nil];
+ }];
if (exception) {
if ([exception.name isEqualToString:UntrustedIdentityKeyException]) {
OWSRaiseExceptionWithUserInfo(UntrustedIdentityKeyException, (@{ TSInvalidPreKeyBundleKey : bundle, TSInvalidRecipientKey : recipientID }), @"");
@@ -1753,7 +1753,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
for (TSAttachmentStream *attachmentStream in attachmentStreams) {
[attachmentStream saveWithTransaction:transaction];
}
- } error:nil];
+ }];
completionHandler(nil);
});
diff --git a/SignalServiceKit/src/Messages/OWSOutgoingReceiptManager.m b/SignalServiceKit/src/Messages/OWSOutgoingReceiptManager.m
index fc95e552c..7d4fc5e67 100644
--- a/SignalServiceKit/src/Messages/OWSOutgoingReceiptManager.m
+++ b/SignalServiceKit/src/Messages/OWSOutgoingReceiptManager.m
@@ -256,7 +256,7 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
[newTimestamps addObject:@(timestamp)];
[transaction setObject:newTimestamps forKey:recipientId inCollection:collection];
- } error:nil];
+ }];
[self process];
});
@@ -287,7 +287,7 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
} else {
[transaction removeObjectForKey:recipientId inCollection:collection];
}
- } error:nil];
+ }];
});
}
diff --git a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m
index a5bdb80d5..b95671d5c 100644
--- a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m
+++ b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m
@@ -219,7 +219,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.messageSenderJobQueue addMessage:message transaction:transaction];
- } error:nil];
+ }];
}
BOOL didWork = readReceiptsForLinkedDevices.count > 0;
@@ -256,7 +256,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
readTimestamp:[NSDate ows_millisecondTimeStamp]
wasLocal:YES
transaction:transaction];
- } error:nil];
+ }];
});
}
@@ -343,7 +343,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
transaction:transaction];
}
}
- } error:nil];
+ }];
});
}
diff --git a/SignalServiceKit/src/Messages/TSCall.m b/SignalServiceKit/src/Messages/TSCall.m
index e7e0118cb..4b197b38c 100644
--- a/SignalServiceKit/src/Messages/TSCall.m
+++ b/SignalServiceKit/src/Messages/TSCall.m
@@ -155,7 +155,7 @@ NSUInteger TSCallCurrentSchemaVersion = 1;
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self updateCallType:callType transaction:transaction];
- } error:nil];
+ }];
}
- (void)updateCallType:(RPRecentCallType)callType transaction:(YapDatabaseReadWriteTransaction *)transaction
diff --git a/SignalServiceKit/src/Messages/UD/OWSUDManager.swift b/SignalServiceKit/src/Messages/UD/OWSUDManager.swift
index 000769c99..cd74e8707 100644
--- a/SignalServiceKit/src/Messages/UD/OWSUDManager.swift
+++ b/SignalServiceKit/src/Messages/UD/OWSUDManager.swift
@@ -241,7 +241,7 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
}
}
- try! Storage.writeSync { (transaction) in
+ Storage.writeSync { (transaction) in
let oldMode = self.unidentifiedAccessMode(forRecipientId: recipientId, isLocalNumber: isLocalNumber, transaction: transaction)
transaction.setObject(mode.rawValue as Int, forKey: recipientId, inCollection: self.kUnidentifiedAccessCollection)
diff --git a/SignalServiceKit/src/Network/MessageSenderJobQueue.swift b/SignalServiceKit/src/Network/MessageSenderJobQueue.swift
index 9a875cb07..c6136f0bd 100644
--- a/SignalServiceKit/src/Network/MessageSenderJobQueue.swift
+++ b/SignalServiceKit/src/Network/MessageSenderJobQueue.swift
@@ -51,11 +51,11 @@ public class MessageSenderJobQueue: NSObject, JobQueue {
inMessage: mediaMessage,
completionHandler: { error in
if let error = error {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
mediaMessage.update(sendingError: error, transaction: transaction)
}
} else {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
self.add(message: mediaMessage, removeMessageAfterSending: isTemporaryAttachment, transaction: transaction)
}
}
@@ -96,7 +96,7 @@ public class MessageSenderJobQueue: NSObject, JobQueue {
/// Used when the user clears their database to cancel any outstanding jobs.
@objc public func clearAllJobs() {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
let statuses: [SSKJobRecordStatus] = [ .unknown, .ready, .running, .permanentlyFailed ]
var records: [SSKJobRecord] = []
statuses.forEach {
@@ -193,7 +193,7 @@ public class MessageSenderOperation: OWSOperation, DurableOperation {
}
override public func didSucceed() {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
self.durableOperationDelegate?.durableOperationDidSucceed(self, transaction: transaction)
if self.jobRecord.removeMessageAfterSending {
@@ -208,7 +208,7 @@ public class MessageSenderOperation: OWSOperation, DurableOperation {
if message is SessionRequestMessage, let publicKey = message.thread.contactIdentifier() {
isFailedSessionRequest = (Storage.getSessionRequestSentTimestamp(for: publicKey) == message.timestamp)
}
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
if isFailedSessionRequest, let publicKey = message.thread.contactIdentifier() {
Storage.setSessionRequestSentTimestamp(for: publicKey, to: 0, using: transaction)
}
@@ -239,7 +239,7 @@ public class MessageSenderOperation: OWSOperation, DurableOperation {
if message is SessionRequestMessage, let publicKey = message.thread.contactIdentifier() {
isFailedSessionRequest = (Storage.getSessionRequestSentTimestamp(for: publicKey) == message.timestamp)
}
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
if isFailedSessionRequest, let publicKey = message.thread.contactIdentifier() {
Storage.setSessionRequestSentTimestamp(for: publicKey, to: 0, using: transaction)
}
diff --git a/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m b/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m
index 7c1ee95ed..5a6968bc3 100644
--- a/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m
+++ b/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m
@@ -799,7 +799,7 @@ NSString *const kNSNotification_OWSWebSocketStateDidChange = @"kNSNotification_O
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
[self.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
transaction:transaction];
- } error:nil];
+ }];
}
dispatch_async(dispatch_get_main_queue(), ^{
diff --git a/SignalServiceKit/src/Security/OWSRecipientIdentity.m b/SignalServiceKit/src/Security/OWSRecipientIdentity.m
index a1ed4bed7..79ed2d660 100644
--- a/SignalServiceKit/src/Security/OWSRecipientIdentity.m
+++ b/SignalServiceKit/src/Security/OWSRecipientIdentity.m
@@ -158,7 +158,7 @@ SSKProtoVerified *_Nullable BuildVerifiedProtoWithRecipientId(NSString *destinat
changeBlock(latest);
[latest saveWithTransaction:transaction];
- } error:nil];
+ }];
}
#pragma mark - debug
diff --git a/SignalServiceKit/src/Storage/TSYapDatabaseObject.m b/SignalServiceKit/src/Storage/TSYapDatabaseObject.m
index 013853160..caf98e414 100644
--- a/SignalServiceKit/src/Storage/TSYapDatabaseObject.m
+++ b/SignalServiceKit/src/Storage/TSYapDatabaseObject.m
@@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self saveWithTransaction:transaction];
- } error:nil];
+ }];
}
- (void)saveAsyncWithCompletionBlock:(void (^_Nullable)(void))completionBlock
@@ -67,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self touchWithTransaction:transaction];
- } error:nil];
+ }];
}
- (void)removeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
@@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self removeWithTransaction:transaction];
- } error:nil];
+ }];
}
- (YapDatabaseConnection *)dbReadConnection
@@ -183,7 +183,7 @@ NS_ASSUME_NONNULL_BEGIN
{
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[transaction removeAllObjectsInCollection:[self collection]];
- } error:nil];
+ }];
}
+ (nullable instancetype)fetchObjectWithUniqueID:(NSString *)uniqueID
diff --git a/SignalServiceKit/src/Util/JobQueue.swift b/SignalServiceKit/src/Util/JobQueue.swift
index 22a07b42f..366c9992c 100644
--- a/SignalServiceKit/src/Util/JobQueue.swift
+++ b/SignalServiceKit/src/Util/JobQueue.swift
@@ -157,7 +157,7 @@ public extension JobQueue {
return
}
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
guard let nextJob: JobRecordType = self.finder.getNextReady(label: self.jobRecordLabel, transaction: transaction) as? JobRecordType else {
Logger.verbose("nothing left to enqueue")
return
@@ -197,7 +197,7 @@ public extension JobQueue {
}
public func restartOldJobs() {
- try! Storage.writeSync { transaction in
+ Storage.writeSync { transaction in
let runningRecords = self.finder.allRecords(label: self.jobRecordLabel, status: .running, transaction: transaction)
Logger.info("marking old `running` JobRecords as ready: \(runningRecords.count)")
for record in runningRecords {
diff --git a/SignalServiceKit/src/Util/OWSAnalytics.m b/SignalServiceKit/src/Util/OWSAnalytics.m
index 28694f221..311419207 100755
--- a/SignalServiceKit/src/Util/OWSAnalytics.m
+++ b/SignalServiceKit/src/Util/OWSAnalytics.m
@@ -191,7 +191,7 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity)
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
// Remove from queue.
[transaction removeObjectForKey:eventKey inCollection:kOWSAnalytics_EventsCollection];
- } error:nil];
+ }];
// Wait a second between network requests / retries.
dispatch_after(
@@ -332,7 +332,7 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity)
}
[transaction setObject:eventDictionary forKey:eventKey inCollection:kOWSAnalytics_EventsCollection];
- } error:nil];
+ }];
[self tryToSyncEvents];
}