Rework the "update with..." methods to avoid re-saving deleted models.

pull/1/head
Matthew Chen 8 years ago
parent 69fa80b890
commit c6160a5a1e

@ -32,7 +32,7 @@ class SessionResetJob: NSObject {
DispatchQueue.main.async { DispatchQueue.main.async {
let endSessionMessage = EndSessionMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: self.thread) let endSessionMessage = EndSessionMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: self.thread)
self.messageSender.send(endSessionMessage, success: { self.messageSender.enqueue(endSessionMessage, success: {
Logger.info("\(self.TAG) successfully sent EndSession<essage.") Logger.info("\(self.TAG) successfully sent EndSession<essage.")
let message = TSInfoMessage(timestamp: NSDate.ows_millisecondTimeStamp(), let message = TSInfoMessage(timestamp: NSDate.ows_millisecondTimeStamp(),
in: self.thread, in: self.thread,

@ -12,7 +12,7 @@ public extension MessageSender {
*/ */
public func sendPromise(message: TSOutgoingMessage) -> Promise<Void> { public func sendPromise(message: TSOutgoingMessage) -> Promise<Void> {
let promise: Promise<Void> = Promise { fulfill, reject in let promise: Promise<Void> = Promise { fulfill, reject in
self.send(message, success: fulfill, failure: reject) self.enqueue(message, success: fulfill, failure: reject)
} }
// Ensure sends complete before they're GC'd. // Ensure sends complete before they're GC'd.

@ -44,7 +44,7 @@ import PromiseKit
profileManager: self.profileManager) profileManager: self.profileManager)
let dataSource = DataSourceValue.dataSource(withSyncMessage: syncContactsMessage.buildPlainTextAttachmentData()) let dataSource = DataSourceValue.dataSource(withSyncMessage: syncContactsMessage.buildPlainTextAttachmentData())
self.messageSender.sendTemporaryAttachmentData(dataSource, self.messageSender.enqueueOutgoingTemporaryAttachment(dataSource,
contentType: OWSMimeTypeApplicationOctetStream, contentType: OWSMimeTypeApplicationOctetStream,
in: syncContactsMessage, in: syncContactsMessage,
success: { success: {

@ -1465,7 +1465,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
return; return;
} }
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent profile key message to thread: %@", self.logTag, thread); DDLogInfo(@"%@ Successfully sent profile key message to thread: %@", self.logTag, thread);
[OWSProfileManager.sharedManager addThreadToProfileWhitelist:thread]; [OWSProfileManager.sharedManager addThreadToProfileWhitelist:thread];

@ -1654,7 +1654,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
[UIAlertAction actionWithTitle:NSLocalizedString(@"SEND_AGAIN_BUTTON", @"") [UIAlertAction actionWithTitle:NSLocalizedString(@"SEND_AGAIN_BUTTON", @"")
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully resent failed message.", self.logTag); DDLogInfo(@"%@ Successfully resent failed message.", self.logTag);
} }
@ -3391,7 +3391,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
if (newGroupModel.groupImage) { if (newGroupModel.groupImage) {
NSData *data = UIImagePNGRepresentation(newGroupModel.groupImage); NSData *data = UIImagePNGRepresentation(newGroupModel.groupImage);
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:data fileExtension:@"png"]; DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:data fileExtension:@"png"];
[self.messageSender sendAttachmentData:dataSource [self.messageSender enqueueOutgoingAttachment:dataSource
contentType:OWSMimeTypeImagePng contentType:OWSMimeTypeImagePng
sourceFilename:nil sourceFilename:nil
inMessage:message inMessage:message
@ -3405,7 +3405,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
DDLogError(@"%@ Failed to send group avatar update with error: %@", self.logTag, error); DDLogError(@"%@ Failed to send group avatar update with error: %@", self.logTag, error);
}]; }];
} else { } else {
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogDebug(@"%@ Successfully sent group update", self.logTag); DDLogDebug(@"%@ Successfully sent group update", self.logTag);
if (successCompletion) { if (successCompletion) {

@ -219,7 +219,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSSyncGroupsRequestMessage *syncGroupsRequestMessage = OWSSyncGroupsRequestMessage *syncGroupsRequestMessage =
[[OWSSyncGroupsRequestMessage alloc] initWithThread:thread [[OWSSyncGroupsRequestMessage alloc] initWithThread:thread
groupId:[Randomness generateRandomBytes:16]]; groupId:[Randomness generateRandomBytes:16]];
[[Environment getCurrent].messageSender sendMessage:syncGroupsRequestMessage [[Environment getCurrent].messageSender enqueueOutgoingMessage:syncGroupsRequestMessage
success:^{ success:^{
DDLogWarn(@"%@ Successfully sent Request Group Info message.", self.logTag); DDLogWarn(@"%@ Successfully sent Request Group Info message.", self.logTag);
} }
@ -1055,7 +1055,6 @@ NS_ASSUME_NONNULL_BEGIN
TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread inThread:thread
groupMetaMessage:TSGroupMessageNew]; groupMetaMessage:TSGroupMessageNew];
// This will save the message.
[message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)]; [message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)];
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment getCurrent].messageSender;
@ -1067,7 +1066,7 @@ NS_ASSUME_NONNULL_BEGIN
}); });
}); });
}; };
[messageSender sendMessage:message [messageSender enqueueOutgoingMessage:message
success:completion success:completion
failure:^(NSError *error) { failure:^(NSError *error) {
completion(); completion();

@ -437,7 +437,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(message); OWSAssert(message);
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment getCurrent].messageSender;
[messageSender sendMessage:message [messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent message.", self.logTag); DDLogInfo(@"%@ Successfully sent message.", self.logTag);
} }

@ -679,7 +679,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread inThread:thread
groupMetaMessage:TSGroupMessageQuit]; groupMetaMessage:TSGroupMessageQuit];
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
[self dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES
completion:^{ completion:^{

@ -493,7 +493,6 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
inThread:thread inThread:thread
groupMetaMessage:TSGroupMessageNew]; groupMetaMessage:TSGroupMessageNew];
// This will save the message.
[message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)]; [message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@ -501,14 +500,16 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
NSData *data = UIImagePNGRepresentation(model.groupImage); NSData *data = UIImagePNGRepresentation(model.groupImage);
DataSource *_Nullable dataSource = DataSource *_Nullable dataSource =
[DataSourceValue dataSourceWithData:data fileExtension:@"png"]; [DataSourceValue dataSourceWithData:data fileExtension:@"png"];
[self.messageSender sendAttachmentData:dataSource [self.messageSender enqueueOutgoingAttachment:dataSource
contentType:OWSMimeTypeImagePng contentType:OWSMimeTypeImagePng
sourceFilename:nil sourceFilename:nil
inMessage:message inMessage:message
success:successHandler success:successHandler
failure:failureHandler]; failure:failureHandler];
} else { } else {
[self.messageSender sendMessage:message success:successHandler failure:failureHandler]; [self.messageSender enqueueOutgoingMessage:message
success:successHandler
failure:failureHandler];
} }
}); });
}]; }];

@ -885,7 +885,7 @@ NS_ASSUME_NONNULL_BEGIN
TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:gThread inThread:gThread
groupMetaMessage:TSGroupMessageQuit]; groupMetaMessage:TSGroupMessageQuit];
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully left group.", self.logTag); DDLogInfo(@"%@ Successfully left group.", self.logTag);
} }

@ -115,7 +115,7 @@ NSString *const kTSStorageManagerOWSContactsSyncingLastMessageKey =
DataSource *dataSource = DataSource *dataSource =
[DataSourceValue dataSourceWithSyncMessage:[syncContactsMessage buildPlainTextAttachmentData]]; [DataSourceValue dataSourceWithSyncMessage:[syncContactsMessage buildPlainTextAttachmentData]];
[self.messageSender sendTemporaryAttachmentData:dataSource [self.messageSender enqueueOutgoingTemporaryAttachment:dataSource
contentType:OWSMimeTypeApplicationOctetStream contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncContactsMessage inMessage:syncContactsMessage
success:^{ success:^{

@ -86,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN
attachmentIds:[NSMutableArray new] attachmentIds:[NSMutableArray new]
expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)]; expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)];
[messageSender sendMessage:message success:successHandler failure:failureHandler]; [messageSender enqueueOutgoingMessage:message success:successHandler failure:failureHandler];
return message; return message;
} }
@ -117,7 +117,7 @@ NS_ASSUME_NONNULL_BEGIN
inThread:thread inThread:thread
isVoiceMessage:[attachment isVoiceMessage] isVoiceMessage:[attachment isVoiceMessage]
expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)]; expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)];
[messageSender sendAttachmentData:attachment.dataSource [messageSender enqueueOutgoingAttachment:attachment.dataSource
contentType:attachment.mimeType contentType:attachment.mimeType
sourceFilename:attachment.filenameOrDefault sourceFilename:attachment.filenameOrDefault
inMessage:message inMessage:message

@ -157,18 +157,19 @@ NS_ASSUME_NONNULL_BEGIN
@property (atomic, readonly, nullable) NSDate *mutedUntilDate; @property (atomic, readonly, nullable) NSDate *mutedUntilDate;
// This model may be updated from many threads. We don't want to save // This model may be updated from many threads. We don't want to save
// our local copy (this instance) since it may be out of date. Instead, we // our local copy (this instance) since it may be out of date. We also
// want to avoid re-saving a model that has been deleted. Therefore, we
// use these "updateWith..." methods to: // use these "updateWith..." methods to:
// //
// a) Update a property of this instance. // a) Update a property of this instance.
// b) Load an up-to-date instance of this model from from the data store. // b) If a copy of this model exists in the database, load an up-to-date copy,
// c) Update and save that fresh instance. // and update and save that copy.
// d) If this instance hasn't yet been saved, save this local instance. // b) If a copy of this model _DOES NOT_ exist in the database, do _NOT_ save
// this local instance.
// //
// After "updateWith...": // After "updateWith...":
// //
// a) An updated copy of this instance will always have been saved in the // a) An copy of this model in the database will have been updated.
// data store.
// b) The local property on this instance will always have been updated. // b) The local property on this instance will always have been updated.
// c) Other properties on this instance may be out of date. // c) Other properties on this instance may be out of date.
// //

@ -384,7 +384,7 @@ NS_ASSUME_NONNULL_BEGIN
// This method does the work for the "updateWith..." methods. Please see // This method does the work for the "updateWith..." methods. Please see
// the header for a discussion of those methods. // the header for a discussion of those methods.
- (void)applyChangeToSelfAndLatestThread:(YapDatabaseReadWriteTransaction *)transaction - (void)applyChangeToSelfAndLatestCopy:(YapDatabaseReadWriteTransaction *)transaction
changeBlock:(void (^)(TSThread *))changeBlock changeBlock:(void (^)(TSThread *))changeBlock
{ {
OWSAssert(transaction); OWSAssert(transaction);
@ -396,16 +396,13 @@ NS_ASSUME_NONNULL_BEGIN
if (latestInstance) { if (latestInstance) {
changeBlock(latestInstance); changeBlock(latestInstance);
[latestInstance saveWithTransaction:transaction]; [latestInstance saveWithTransaction:transaction];
} else {
// This message has not yet been saved.
[self saveWithTransaction:transaction];
} }
} }
- (void)updateWithMutedUntilDate:(NSDate *)mutedUntilDate - (void)updateWithMutedUntilDate:(NSDate *)mutedUntilDate
{ {
[self.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self applyChangeToSelfAndLatestThread:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSThread *thread) { changeBlock:^(TSThread *thread) {
[thread setMutedUntilDate:mutedUntilDate]; [thread setMutedUntilDate:mutedUntilDate];
}]; }];

@ -109,6 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
return; return;
} }
[outgoingMessage saveWithTransaction:transaction];
[outgoingMessage updateWithWasSentFromLinkedDeviceWithTransaction:transaction]; [outgoingMessage updateWithWasSentFromLinkedDeviceWithTransaction:transaction];
[OWSDisappearingMessagesJob becomeConsistentWithConfigurationForMessage:outgoingMessage [OWSDisappearingMessagesJob becomeConsistentWithConfigurationForMessage:outgoingMessage
contactsManager:self.contactsManager]; contactsManager:self.contactsManager];
@ -138,6 +139,7 @@ NS_ASSUME_NONNULL_BEGIN
expiresInSeconds:transcript.expirationDuration expiresInSeconds:transcript.expirationDuration
expireStartedAt:transcript.expirationStartedAt]; expireStartedAt:transcript.expirationStartedAt];
// Since textMessage is a new message, updateWithWasSentAndDelivered will save it. // Since textMessage is a new message, updateWithWasSentAndDelivered will save it.
[textMessage saveWithTransaction:transaction];
[textMessage updateWithWasSentFromLinkedDeviceWithTransaction:transaction]; [textMessage updateWithWasSentFromLinkedDeviceWithTransaction:transaction];
} }
} }

@ -148,19 +148,20 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
- (OWSSignalServiceProtosAttachmentPointer *)buildAttachmentProtoForAttachmentId:(NSString *)attachmentId - (OWSSignalServiceProtosAttachmentPointer *)buildAttachmentProtoForAttachmentId:(NSString *)attachmentId
filename:(nullable NSString *)filename; filename:(nullable NSString *)filename;
// TSOutgoingMessage are updated from many threads. We don't want to save // This model may be updated from many threads. We don't want to save
// our local copy (this instance) since it may be out of date. Instead, we // our local copy (this instance) since it may be out of date. We also
// want to avoid re-saving a model that has been deleted. Therefore, we
// use these "updateWith..." methods to: // use these "updateWith..." methods to:
// //
// a) Update a property of this instance. // a) Update a property of this instance.
// b) Load an up-to-date instance of this model from from the data store. // b) If a copy of this model exists in the database, load an up-to-date copy,
// c) Update and save that fresh instance. // and update and save that copy.
// d) If this message hasn't yet been saved, save this local instance. // b) If a copy of this model _DOES NOT_ exist in the database, do _NOT_ save
// this local instance.
// //
// After "updateWith...": // After "updateWith...":
// //
// a) An updated copy of this message will always have been saved in the // a) An copy of this model in the database will have been updated.
// data store.
// b) The local property on this instance will always have been updated. // b) The local property on this instance will always have been updated.
// c) Other properties on this instance may be out of date. // c) Other properties on this instance may be out of date.
// //

@ -242,7 +242,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
// This method does the work for the "updateWith..." methods. Please see // This method does the work for the "updateWith..." methods. Please see
// the header for a discussion of those methods. // the header for a discussion of those methods.
- (void)applyChangeToSelfAndLatestOutgoingMessage:(YapDatabaseReadWriteTransaction *)transaction - (void)applyChangeToSelfAndLatestCopy:(YapDatabaseReadWriteTransaction *)transaction
changeBlock:(void (^)(TSOutgoingMessage *))changeBlock changeBlock:(void (^)(TSOutgoingMessage *))changeBlock
{ {
OWSAssert(transaction); OWSAssert(transaction);
@ -254,9 +254,6 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
if (latestMessage) { if (latestMessage) {
changeBlock(latestMessage); changeBlock(latestMessage);
[latestMessage saveWithTransaction:transaction]; [latestMessage saveWithTransaction:transaction];
} else {
// This message has not yet been saved.
[self saveWithTransaction:transaction];
} }
} }
@ -265,7 +262,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
OWSAssert(error); OWSAssert(error);
[self.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self applyChangeToSelfAndLatestOutgoingMessage:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
[message setMessageState:TSOutgoingMessageStateUnsent]; [message setMessageState:TSOutgoingMessageStateUnsent];
[message setMostRecentFailureText:error.localizedDescription]; [message setMostRecentFailureText:error.localizedDescription];
@ -285,7 +282,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
{ {
OWSAssert(transaction); OWSAssert(transaction);
[self applyChangeToSelfAndLatestOutgoingMessage:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
[message setMessageState:messageState]; [message setMessageState:messageState];
}]; }];
@ -294,7 +291,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
- (void)updateWithHasSyncedTranscript:(BOOL)hasSyncedTranscript - (void)updateWithHasSyncedTranscript:(BOOL)hasSyncedTranscript
transaction:(YapDatabaseReadWriteTransaction *)transaction transaction:(YapDatabaseReadWriteTransaction *)transaction
{ {
[self applyChangeToSelfAndLatestOutgoingMessage:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
[message setHasSyncedTranscript:hasSyncedTranscript]; [message setHasSyncedTranscript:hasSyncedTranscript];
}]; }];
@ -305,7 +302,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
OWSAssert(customMessage); OWSAssert(customMessage);
OWSAssert(transaction); OWSAssert(transaction);
[self applyChangeToSelfAndLatestOutgoingMessage:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
[message setCustomMessage:customMessage]; [message setCustomMessage:customMessage];
}]; }];
@ -325,13 +322,12 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
OWSAssert(transaction); OWSAssert(transaction);
[self applyChangeToSelfAndLatestOutgoingMessage:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
if (deliveryTimestamp) { if (deliveryTimestamp) {
NSMutableDictionary<NSString *, NSNumber *> *recipientDeliveryMap NSMutableDictionary<NSString *, NSNumber *> *recipientDeliveryMap
= (message.recipientDeliveryMap = (message.recipientDeliveryMap ? [message.recipientDeliveryMap mutableCopy]
? [message.recipientDeliveryMap mutableCopy]
: [NSMutableDictionary new]); : [NSMutableDictionary new]);
recipientDeliveryMap[recipientId] = deliveryTimestamp; recipientDeliveryMap[recipientId] = deliveryTimestamp;
message.recipientDeliveryMap = [recipientDeliveryMap copy]; message.recipientDeliveryMap = [recipientDeliveryMap copy];
@ -345,7 +341,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
{ {
OWSAssert(transaction); OWSAssert(transaction);
[self applyChangeToSelfAndLatestOutgoingMessage:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
[message setMessageState:TSOutgoingMessageStateSentToService]; [message setMessageState:TSOutgoingMessageStateSentToService];
[message setWasDelivered:YES]; [message setWasDelivered:YES];
@ -359,7 +355,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
OWSAssert(transaction); OWSAssert(transaction);
OWSAssert(singleGroupRecipient.length > 0); OWSAssert(singleGroupRecipient.length > 0);
[self applyChangeToSelfAndLatestOutgoingMessage:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
[message setSingleGroupRecipient:singleGroupRecipient]; [message setSingleGroupRecipient:singleGroupRecipient];
}]; }];
@ -414,7 +410,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
- (void)updateWithSentRecipient:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction - (void)updateWithSentRecipient:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction
{ {
OWSAssert(transaction); OWSAssert(transaction);
[self applyChangeToSelfAndLatestOutgoingMessage:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
[message addSentRecipient:contactId]; [message addSentRecipient:contactId];
}]; }];
@ -427,7 +423,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
OWSAssert(transaction); OWSAssert(transaction);
[self applyChangeToSelfAndLatestOutgoingMessage:transaction [self applyChangeToSelfAndLatestCopy:transaction
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
NSMutableDictionary<NSString *, NSNumber *> *recipientReadMap NSMutableDictionary<NSString *, NSNumber *> *recipientReadMap
= (message.recipientReadMap ? [message.recipientReadMap mutableCopy] = (message.recipientReadMap ? [message.recipientReadMap mutableCopy]

@ -258,7 +258,7 @@ NSString *const kOWSBlockingManager_SyncedBlockedPhoneNumbersKey = @"kOWSBlockin
OWSBlockedPhoneNumbersMessage *message = OWSBlockedPhoneNumbersMessage *message =
[[OWSBlockedPhoneNumbersMessage alloc] initWithPhoneNumbers:blockedPhoneNumbers]; [[OWSBlockedPhoneNumbersMessage alloc] initWithPhoneNumbers:blockedPhoneNumbers];
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent blocked phone numbers sync message", self.logTag); DDLogInfo(@"%@ Successfully sent blocked phone numbers sync message", self.logTag);

@ -517,10 +517,10 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
// subsequently // subsequently
OWSOutgoingNullMessage *nullMessage = [[OWSOutgoingNullMessage alloc] initWithContactThread:contactThread OWSOutgoingNullMessage *nullMessage = [[OWSOutgoingNullMessage alloc] initWithContactThread:contactThread
verificationStateSyncMessage:message]; verificationStateSyncMessage:message];
[self.messageSender sendMessage:nullMessage [self.messageSender enqueueOutgoingMessage:nullMessage
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent verification state NullMessage", self.logTag); DDLogInfo(@"%@ Successfully sent verification state NullMessage", self.logTag);
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent verification state sync message", self.logTag); DDLogInfo(@"%@ Successfully sent verification state sync message", self.logTag);

@ -366,7 +366,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSSyncGroupsRequestMessage *syncGroupsRequestMessage = OWSSyncGroupsRequestMessage *syncGroupsRequestMessage =
[[OWSSyncGroupsRequestMessage alloc] initWithThread:thread groupId:groupId]; [[OWSSyncGroupsRequestMessage alloc] initWithThread:thread groupId:groupId];
[self.messageSender sendMessage:syncGroupsRequestMessage [self.messageSender enqueueOutgoingMessage:syncGroupsRequestMessage
success:^{ success:^{
DDLogWarn(@"%@ Successfully sent Request Group Info message.", self.logTag); DDLogWarn(@"%@ Successfully sent Request Group Info message.", self.logTag);
} }
@ -609,7 +609,7 @@ NS_ASSUME_NONNULL_BEGIN
profileManager:self.profileManager]; profileManager:self.profileManager];
DataSource *dataSource = DataSource *dataSource =
[DataSourceValue dataSourceWithSyncMessage:[syncContactsMessage buildPlainTextAttachmentData]]; [DataSourceValue dataSourceWithSyncMessage:[syncContactsMessage buildPlainTextAttachmentData]];
[self.messageSender sendTemporaryAttachmentData:dataSource [self.messageSender enqueueOutgoingTemporaryAttachment:dataSource
contentType:OWSMimeTypeApplicationOctetStream contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncContactsMessage inMessage:syncContactsMessage
success:^{ success:^{
@ -622,7 +622,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init]; OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init];
DataSource *dataSource = [DataSourceValue DataSource *dataSource = [DataSourceValue
dataSourceWithSyncMessage:[syncGroupsMessage buildPlainTextAttachmentDataWithTransaction:transaction]]; dataSourceWithSyncMessage:[syncGroupsMessage buildPlainTextAttachmentDataWithTransaction:transaction]];
[self.messageSender sendTemporaryAttachmentData:dataSource [self.messageSender enqueueOutgoingTemporaryAttachment:dataSource
contentType:OWSMimeTypeApplicationOctetStream contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncGroupsMessage inMessage:syncGroupsMessage
success:^{ success:^{
@ -639,7 +639,7 @@ NS_ASSUME_NONNULL_BEGIN
[[OWSReadReceiptManager sharedManager] areReadReceiptsEnabledWithTransaction:transaction]; [[OWSReadReceiptManager sharedManager] areReadReceiptsEnabledWithTransaction:transaction];
OWSSyncConfigurationMessage *syncConfigurationMessage = OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled]; [[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled];
[self.messageSender sendMessage:syncConfigurationMessage [self.messageSender enqueueOutgoingMessage:syncConfigurationMessage
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent Configuration response syncMessage.", self.logTag); DDLogInfo(@"%@ Successfully sent Configuration response syncMessage.", self.logTag);
} }
@ -774,7 +774,7 @@ NS_ASSUME_NONNULL_BEGIN
if (gThread.groupModel.groupImage) { if (gThread.groupModel.groupImage) {
NSData *data = UIImagePNGRepresentation(gThread.groupModel.groupImage); NSData *data = UIImagePNGRepresentation(gThread.groupModel.groupImage);
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:data fileExtension:@"png"]; DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:data fileExtension:@"png"];
[self.messageSender sendAttachmentData:dataSource [self.messageSender enqueueOutgoingAttachment:dataSource
contentType:OWSMimeTypeImagePng contentType:OWSMimeTypeImagePng
sourceFilename:nil sourceFilename:nil
inMessage:message inMessage:message
@ -785,7 +785,7 @@ NS_ASSUME_NONNULL_BEGIN
DDLogError(@"%@ Failed to send group avatar update with error: %@", self.logTag, error); DDLogError(@"%@ Failed to send group avatar update with error: %@", self.logTag, error);
}]; }];
} else { } else {
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogDebug(@"%@ Successfully sent group update", self.logTag); DDLogDebug(@"%@ Successfully sent group update", self.logTag);
} }

@ -63,10 +63,10 @@ NS_SWIFT_NAME(MessageSender)
/** /**
* Send and resend text messages or resend messages with existing attachments. * Send and resend text messages or resend messages with existing attachments.
* If you haven't yet created the attachment, see the `sendAttachmentData:` variants. * If you haven't yet created the attachment, see the ` enqueueOutgoingAttachment:` variants.
*/ */
// TODO: make transaction nonnull and remove `sendMessage:success:failure` // TODO: make transaction nonnull and remove `sendMessage:success:failure`
- (void)sendMessage:(TSOutgoingMessage *)message - (void)enqueueOutgoingMessage:(TSOutgoingMessage *)message
success:(void (^)(void))successHandler success:(void (^)(void))successHandler
failure:(void (^)(NSError *error))failureHandler; failure:(void (^)(NSError *error))failureHandler;
@ -74,7 +74,7 @@ NS_SWIFT_NAME(MessageSender)
* Takes care of allocating and uploading the attachment, then sends the message. * Takes care of allocating and uploading the attachment, then sends the message.
* Only necessary to call once. If sending fails, retry with `sendMessage:`. * Only necessary to call once. If sending fails, retry with `sendMessage:`.
*/ */
- (void)sendAttachmentData:(DataSource *)dataSource - (void)enqueueOutgoingAttachment:(DataSource *)dataSource
contentType:(NSString *)contentType contentType:(NSString *)contentType
sourceFilename:(nullable NSString *)sourceFilename sourceFilename:(nullable NSString *)sourceFilename
inMessage:(TSOutgoingMessage *)outgoingMessage inMessage:(TSOutgoingMessage *)outgoingMessage
@ -82,10 +82,10 @@ NS_SWIFT_NAME(MessageSender)
failure:(void (^)(NSError *error))failureHandler; failure:(void (^)(NSError *error))failureHandler;
/** /**
* Same as `sendAttachmentData:`, but deletes the local copy of the attachment after sending. * Same as ` enqueueOutgoingAttachment:`, but deletes the local copy of the attachment after sending.
* Used for sending sync request data, not for user visible attachments. * Used for sending sync request data, not for user visible attachments.
*/ */
- (void)sendTemporaryAttachmentData:(DataSource *)dataSource - (void)enqueueOutgoingTemporaryAttachment:(DataSource *)dataSource
contentType:(NSString *)contentType contentType:(NSString *)contentType
inMessage:(TSOutgoingMessage *)outgoingMessage inMessage:(TSOutgoingMessage *)outgoingMessage
success:(void (^)(void))successHandler success:(void (^)(void))successHandler

@ -155,7 +155,7 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
@property (nonatomic, readonly) TSOutgoingMessage *message; @property (nonatomic, readonly) TSOutgoingMessage *message;
@property (nonatomic, readonly) OWSMessageSender *messageSender; @property (nonatomic, readonly) OWSMessageSender *messageSender;
@property (nonatomic, readonly) void (^successHandler)(); @property (nonatomic, readonly) void (^successHandler)(void);
@property (nonatomic, readonly) void (^failureHandler)(NSError *_Nonnull error); @property (nonatomic, readonly) void (^failureHandler)(NSError *_Nonnull error);
@property (nonatomic) OWSSendMessageOperationState operationState; @property (nonatomic) OWSSendMessageOperationState operationState;
@property (nonatomic) UIBackgroundTaskIdentifier backgroundTaskIdentifier; @property (nonatomic) UIBackgroundTaskIdentifier backgroundTaskIdentifier;
@ -190,12 +190,7 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
return; return;
} }
// Update the message unless it has been deleted.
if ([TSOutgoingMessage fetchObjectWithUniqueID:message.uniqueId]) {
[message updateWithMessageState:TSOutgoingMessageStateSentToService]; [message updateWithMessageState:TSOutgoingMessageStateSentToService];
} else {
DDLogInfo(@"%@ not marking message sent; message deleted.", strongSelf.logTag);
}
aSuccessHandler(); aSuccessHandler();
@ -209,12 +204,7 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
return; return;
} }
// Update the message unless it has been deleted.
if ([TSOutgoingMessage fetchObjectWithUniqueID:message.uniqueId]) {
[strongSelf.message updateWithSendingError:error]; [strongSelf.message updateWithSendingError:error];
} else {
DDLogInfo(@"%@ not marking message failed; message deleted.", strongSelf.logTag);
}
DDLogDebug(@"%@ failed with error: %@", strongSelf.logTag, error); DDLogDebug(@"%@ failed with error: %@", strongSelf.logTag, error);
aFailureHandler(error); aFailureHandler(error);
@ -429,7 +419,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
} }
} }
- (void)sendMessage:(TSOutgoingMessage *)message - (void)enqueueOutgoingMessage:(TSOutgoingMessage *)message
success:(void (^)(void))successHandler success:(void (^)(void))successHandler
failure:(void (^)(NSError *error))failureHandler failure:(void (^)(NSError *error))failureHandler
{ {
@ -448,7 +438,11 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
// //
// So we're using YDB behavior to ensure this invariant, which is a bit // So we're using YDB behavior to ensure this invariant, which is a bit
// unorthodox. // unorthodox.
[message updateWithMessageState:TSOutgoingMessageStateAttemptingOut]; [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
// All outgoing messages should be saved at the time they are enqueued.
[message saveWithTransaction:transaction];
[message updateWithMessageState:TSOutgoingMessageStateAttemptingOut transaction:transaction];
}];
OWSSendMessageOperation *sendMessageOperation = OWSSendMessageOperation *sendMessageOperation =
[[OWSSendMessageOperation alloc] initWithMessage:message [[OWSSendMessageOperation alloc] initWithMessage:message
@ -476,10 +470,11 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
{ {
[self ensureAnyAttachmentsUploaded:message [self ensureAnyAttachmentsUploaded:message
success:^() { success:^() {
[self deliverMessage:message [self sendMessageToService:message
success:successHandler success:successHandler
failure:^(NSError *error) { failure:^(NSError *error) {
DDLogDebug(@"%@ Message send attempt failed: %@", self.logTag, message.debugDescription); DDLogDebug(
@"%@ Message send attempt failed: %@", self.logTag, message.debugDescription);
failureHandler(error); failureHandler(error);
}]; }];
} }
@ -514,7 +509,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
failure:failureHandler]; failure:failureHandler];
} }
- (void)sendTemporaryAttachmentData:(DataSource *)dataSource - (void)enqueueOutgoingTemporaryAttachment:(DataSource *)dataSource
contentType:(NSString *)contentType contentType:(NSString *)contentType
inMessage:(TSOutgoingMessage *)message inMessage:(TSOutgoingMessage *)message
success:(void (^)(void))successHandler success:(void (^)(void))successHandler
@ -522,7 +517,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
{ {
OWSAssert(dataSource); OWSAssert(dataSource);
void (^successWithDeleteHandler)() = ^() { void (^successWithDeleteHandler)(void) = ^() {
successHandler(); successHandler();
DDLogDebug(@"Removing temporary attachment message."); DDLogDebug(@"Removing temporary attachment message.");
@ -536,7 +531,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[message remove]; [message remove];
}; };
[self sendAttachmentData:dataSource [self enqueueOutgoingAttachment:dataSource
contentType:contentType contentType:contentType
sourceFilename:nil sourceFilename:nil
inMessage:message inMessage:message
@ -544,7 +539,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
failure:failureWithDeleteHandler]; failure:failureWithDeleteHandler];
} }
- (void)sendAttachmentData:(DataSource *)dataSource - (void)enqueueOutgoingAttachment:(DataSource *)dataSource
contentType:(NSString *)contentType contentType:(NSString *)contentType
sourceFilename:(nullable NSString *)sourceFilename sourceFilename:(nullable NSString *)sourceFilename
inMessage:(TSOutgoingMessage *)message inMessage:(TSOutgoingMessage *)message
@ -573,9 +568,8 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
if (sourceFilename) { if (sourceFilename) {
message.attachmentFilenameMap[attachmentStream.uniqueId] = sourceFilename; message.attachmentFilenameMap[attachmentStream.uniqueId] = sourceFilename;
} }
[message save];
[self sendMessage:message success:successHandler failure:failureHandler]; [self enqueueOutgoingMessage:message success:successHandler failure:failureHandler];
}); });
} }
@ -605,7 +599,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
return [recipients copy]; return [recipients copy];
} }
- (void)deliverMessage:(TSOutgoingMessage *)message - (void)sendMessageToService:(TSOutgoingMessage *)message
success:(void (^)(void))successHandler success:(void (^)(void))successHandler
failure:(RetryableFailureHandler)failureHandler failure:(RetryableFailureHandler)failureHandler
{ {
@ -693,7 +687,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
return; return;
} }
[self sendMessage:message [self sendMessageToService:message
recipient:recipient recipient:recipient
thread:thread thread:thread
attempts:OWSMessageSenderRetryAttempts attempts:OWSMessageSenderRetryAttempts
@ -717,7 +711,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
{ {
TOCFutureSource *futureSource = [[TOCFutureSource alloc] init]; TOCFutureSource *futureSource = [[TOCFutureSource alloc] init];
[self sendMessage:message [self sendMessageToService:message
recipient:recipient recipient:recipient
thread:thread thread:thread
attempts:OWSMessageSenderRetryAttempts attempts:OWSMessageSenderRetryAttempts
@ -852,7 +846,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
}]; }];
} }
- (void)sendMessage:(TSOutgoingMessage *)message - (void)sendMessageToService:(TSOutgoingMessage *)message
recipient:(SignalRecipient *)recipient recipient:(SignalRecipient *)recipient
thread:(TSThread *)thread thread:(TSThread *)thread
attempts:(int)remainingAttempts attempts:(int)remainingAttempts
@ -1048,7 +1042,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
long statuscode = response.statusCode; long statuscode = response.statusCode;
NSData *responseData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; NSData *responseData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey];
void (^retrySend)() = ^void() { void (^retrySend)(void) = ^void() {
if (remainingAttempts <= 0) { if (remainingAttempts <= 0) {
// Since we've already repeatedly failed to send to the messaging API, // Since we've already repeatedly failed to send to the messaging API,
// it's unlikely that repeating the whole process will succeed. // it's unlikely that repeating the whole process will succeed.
@ -1058,7 +1052,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
dispatch_async([OWSDispatch sendingQueue], ^{ dispatch_async([OWSDispatch sendingQueue], ^{
DDLogDebug(@"%@ Retrying: %@", self.logTag, message.debugDescription); DDLogDebug(@"%@ Retrying: %@", self.logTag, message.debugDescription);
[self sendMessage:message [self sendMessageToService:message
recipient:recipient recipient:recipient
thread:thread thread:thread
attempts:remainingAttempts attempts:remainingAttempts
@ -1173,12 +1167,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
// TODO: I suspect we shouldn't optimistically set hasSyncedTranscript. // TODO: I suspect we shouldn't optimistically set hasSyncedTranscript.
// We could set this in a success handler for [sendSyncTranscriptForMessage:]. // We could set this in a success handler for [sendSyncTranscriptForMessage:].
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
// Update the message unless it has been deleted.
if ([TSOutgoingMessage fetchObjectWithUniqueID:message.uniqueId]) {
[message updateWithHasSyncedTranscript:YES transaction:transaction]; [message updateWithHasSyncedTranscript:YES transaction:transaction];
} else {
DDLogInfo(@"%@ not marking message as having synced transcript; message deleted.", self.logTag);
}
}]; }];
[self sendSyncTranscriptForMessage:message]; [self sendSyncTranscriptForMessage:message];
} }
@ -1259,7 +1248,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
OWSOutgoingSentMessageTranscript *sentMessageTranscript = OWSOutgoingSentMessageTranscript *sentMessageTranscript =
[[OWSOutgoingSentMessageTranscript alloc] initWithOutgoingMessage:message]; [[OWSOutgoingSentMessageTranscript alloc] initWithOutgoingMessage:message];
[self sendMessage:sentMessageTranscript [self sendMessageToService:sentMessageTranscript
recipient:[SignalRecipient selfRecipient] recipient:[SignalRecipient selfRecipient]
thread:message.thread thread:message.thread
attempts:OWSMessageSenderRetryAttempts attempts:OWSMessageSenderRetryAttempts

@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
[[OWSDisappearingMessagesConfigurationMessage alloc] initWithConfiguration:self.configuration [[OWSDisappearingMessagesConfigurationMessage alloc] initWithConfiguration:self.configuration
thread:self.thread]; thread:self.thread];
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogDebug( DDLogDebug(
@"%@ Successfully notified %@ of new disappearing messages configuration", self.logTag, self.thread); @"%@ Successfully notified %@ of new disappearing messages configuration", self.logTag, self.thread);

@ -229,7 +229,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
OWSReadReceiptsForLinkedDevicesMessage *message = OWSReadReceiptsForLinkedDevicesMessage *message =
[[OWSReadReceiptsForLinkedDevicesMessage alloc] initWithReadReceipts:readReceiptsForLinkedDevices]; [[OWSReadReceiptsForLinkedDevicesMessage alloc] initWithReadReceipts:readReceiptsForLinkedDevices];
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent %zd read receipt to linked devices.", DDLogInfo(@"%@ Successfully sent %zd read receipt to linked devices.",
self.logTag, self.logTag,
@ -253,7 +253,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
[[OWSReadReceiptsForSenderMessage alloc] initWithThread:thread [[OWSReadReceiptsForSenderMessage alloc] initWithThread:thread
messageTimestamps:timestamps.allObjects]; messageTimestamps:timestamps.allObjects];
[self.messageSender sendMessage:message [self.messageSender enqueueOutgoingMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent %zd read receipts to sender.", self.logTag, timestamps.count); DDLogInfo(@"%@ Successfully sent %zd read receipts to sender.", self.logTag, timestamps.count);
} }
@ -590,7 +590,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
OWSSyncConfigurationMessage *syncConfigurationMessage = OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:value]; [[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:value];
[self.messageSender sendMessage:syncConfigurationMessage [self.messageSender enqueueOutgoingMessage:syncConfigurationMessage
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent Configuration syncMessage.", self.logTag); DDLogInfo(@"%@ Successfully sent Configuration syncMessage.", self.logTag);
} }

Loading…
Cancel
Save