Fix unnecessarily throwing function
This commit is contained in:
parent
021d583d75
commit
657d615873
|
@ -6,14 +6,10 @@
|
|||
<dict>
|
||||
<key>CarthageVersion</key>
|
||||
<string>0.36.0</string>
|
||||
<key>DateTime</key>
|
||||
<string>Tue Oct 27 21:55:52 UTC 2020</string>
|
||||
<key>OSXVersion</key>
|
||||
<string>10.15.6</string>
|
||||
<key>WebRTCCommit</key>
|
||||
<string>1445d719bf05280270e9f77576f80f973fd847f8 M73</string>
|
||||
<key>XCodeVersion</key>
|
||||
<string>1200.1210</string>
|
||||
</dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<String> = []
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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<TSGroupThread> in
|
||||
var promise: Promise<TSGroupThread>!
|
||||
try! Storage.writeSync { transaction in
|
||||
Storage.writeSync { transaction in
|
||||
promise = ClosedGroupsProtocol.createClosedGroup(name: name, members: selectedContacts, transaction: transaction)
|
||||
}
|
||||
return promise
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -531,7 +531,7 @@ typedef void (^CustomLayoutBlock)(void);
|
|||
recipientId:self.recipientId
|
||||
isUserInitiatedChange:YES
|
||||
transaction:transaction];
|
||||
} error:nil];
|
||||
}];
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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)];
|
||||
}
|
||||
|
|
|
@ -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<NSString *> *)activeRecordNames
|
||||
|
|
|
@ -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.")];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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."];
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -712,7 +712,7 @@ typedef void (^BuildOutgoingMessageCompletionBlock)(TSOutgoingMessage *savedMess
|
|||
} @catch (NSException *exception) {
|
||||
// Do nothing
|
||||
}
|
||||
} error:nil];
|
||||
}];
|
||||
[TSAttachmentStream deleteAttachments];
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[SignalRecipient markRecipientAsUnregistered:recipientId transaction:transaction];
|
||||
}
|
||||
}
|
||||
} error:nil];
|
||||
}];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
success([recipients copy]);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: %@",
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
});
|
||||
|
|
|
@ -88,7 +88,7 @@ static NSString *const OWSFailedAttachmentDownloadsJobAttachmentStateIndex = @"i
|
|||
}
|
||||
}
|
||||
transaction:transaction];
|
||||
} error:nil];
|
||||
}];
|
||||
|
||||
OWSLogDebug(@"Marked %u attachments as unsent", count);
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ static NSString *const OWSFailedMessagesJobMessageStateIndex = @"index_outoing_m
|
|||
count++;
|
||||
}
|
||||
transaction:transaction];
|
||||
} error:nil];
|
||||
}];
|
||||
|
||||
OWSLogDebug(@"Marked %u messages as unsent", count);
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ static NSString *const OWSIncompleteCallsJobCallTypeIndex = @"index_calls_on_cal
|
|||
count++;
|
||||
}
|
||||
transaction:transaction];
|
||||
} error:nil];
|
||||
}];
|
||||
|
||||
OWSLogInfo(@"Marked %u calls as missed", count);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: %@.",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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];
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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(), ^{
|
||||
|
|
|
@ -158,7 +158,7 @@ SSKProtoVerified *_Nullable BuildVerifiedProtoWithRecipientId(NSString *destinat
|
|||
|
||||
changeBlock(latest);
|
||||
[latest saveWithTransaction:transaction];
|
||||
} error:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - debug
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue