|
|
|
|
@ -242,7 +242,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
|
|
|
|
|
// This method does the work for the "updateWith..." methods. Please see
|
|
|
|
|
// the header for a discussion of those methods.
|
|
|
|
|
- (void)applyChangeToSelfAndLatestCopy:(YapDatabaseReadWriteTransaction *)transaction
|
|
|
|
|
- (void)applyChangeToSelfAndLatestOutgoingMessage:(YapDatabaseReadWriteTransaction *)transaction
|
|
|
|
|
changeBlock:(void (^)(TSOutgoingMessage *))changeBlock
|
|
|
|
|
{
|
|
|
|
|
OWSAssert(transaction);
|
|
|
|
|
@ -262,7 +262,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
OWSAssert(error);
|
|
|
|
|
|
|
|
|
|
[self.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
|
|
|
[self applyChangeToSelfAndLatestOutgoingMessage:transaction
|
|
|
|
|
changeBlock:^(TSOutgoingMessage *message) {
|
|
|
|
|
[message setMessageState:TSOutgoingMessageStateUnsent];
|
|
|
|
|
[message setMostRecentFailureText:error.localizedDescription];
|
|
|
|
|
@ -282,7 +282,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
{
|
|
|
|
|
OWSAssert(transaction);
|
|
|
|
|
|
|
|
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
|
|
|
[self applyChangeToSelfAndLatestOutgoingMessage:transaction
|
|
|
|
|
changeBlock:^(TSOutgoingMessage *message) {
|
|
|
|
|
[message setMessageState:messageState];
|
|
|
|
|
}];
|
|
|
|
|
@ -291,7 +291,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
- (void)updateWithHasSyncedTranscript:(BOOL)hasSyncedTranscript
|
|
|
|
|
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
|
|
|
|
{
|
|
|
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
|
|
|
[self applyChangeToSelfAndLatestOutgoingMessage:transaction
|
|
|
|
|
changeBlock:^(TSOutgoingMessage *message) {
|
|
|
|
|
[message setHasSyncedTranscript:hasSyncedTranscript];
|
|
|
|
|
}];
|
|
|
|
|
@ -302,7 +302,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
OWSAssert(customMessage);
|
|
|
|
|
OWSAssert(transaction);
|
|
|
|
|
|
|
|
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
|
|
|
[self applyChangeToSelfAndLatestOutgoingMessage:transaction
|
|
|
|
|
changeBlock:^(TSOutgoingMessage *message) {
|
|
|
|
|
[message setCustomMessage:customMessage];
|
|
|
|
|
}];
|
|
|
|
|
@ -322,12 +322,13 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
OWSAssert(recipientId.length > 0);
|
|
|
|
|
OWSAssert(transaction);
|
|
|
|
|
|
|
|
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
|
|
|
[self applyChangeToSelfAndLatestOutgoingMessage:transaction
|
|
|
|
|
changeBlock:^(TSOutgoingMessage *message) {
|
|
|
|
|
|
|
|
|
|
if (deliveryTimestamp) {
|
|
|
|
|
NSMutableDictionary<NSString *, NSNumber *> *recipientDeliveryMap
|
|
|
|
|
= (message.recipientDeliveryMap ? [message.recipientDeliveryMap mutableCopy]
|
|
|
|
|
= (message.recipientDeliveryMap
|
|
|
|
|
? [message.recipientDeliveryMap mutableCopy]
|
|
|
|
|
: [NSMutableDictionary new]);
|
|
|
|
|
recipientDeliveryMap[recipientId] = deliveryTimestamp;
|
|
|
|
|
message.recipientDeliveryMap = [recipientDeliveryMap copy];
|
|
|
|
|
@ -341,7 +342,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
{
|
|
|
|
|
OWSAssert(transaction);
|
|
|
|
|
|
|
|
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
|
|
|
[self applyChangeToSelfAndLatestOutgoingMessage:transaction
|
|
|
|
|
changeBlock:^(TSOutgoingMessage *message) {
|
|
|
|
|
[message setMessageState:TSOutgoingMessageStateSentToService];
|
|
|
|
|
[message setWasDelivered:YES];
|
|
|
|
|
@ -355,7 +356,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
OWSAssert(transaction);
|
|
|
|
|
OWSAssert(singleGroupRecipient.length > 0);
|
|
|
|
|
|
|
|
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
|
|
|
[self applyChangeToSelfAndLatestOutgoingMessage:transaction
|
|
|
|
|
changeBlock:^(TSOutgoingMessage *message) {
|
|
|
|
|
[message setSingleGroupRecipient:singleGroupRecipient];
|
|
|
|
|
}];
|
|
|
|
|
@ -410,7 +411,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
- (void)updateWithSentRecipient:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction
|
|
|
|
|
{
|
|
|
|
|
OWSAssert(transaction);
|
|
|
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
|
|
|
[self applyChangeToSelfAndLatestOutgoingMessage:transaction
|
|
|
|
|
changeBlock:^(TSOutgoingMessage *message) {
|
|
|
|
|
[message addSentRecipient:contactId];
|
|
|
|
|
}];
|
|
|
|
|
@ -423,7 +424,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|
|
|
|
OWSAssert(recipientId.length > 0);
|
|
|
|
|
OWSAssert(transaction);
|
|
|
|
|
|
|
|
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
|
|
|
[self applyChangeToSelfAndLatestOutgoingMessage:transaction
|
|
|
|
|
changeBlock:^(TSOutgoingMessage *message) {
|
|
|
|
|
NSMutableDictionary<NSString *, NSNumber *> *recipientReadMap
|
|
|
|
|
= (message.recipientReadMap ? [message.recipientReadMap mutableCopy]
|
|
|
|
|
|