From 9d5e079e1c7c9dcef4196213b2756cf6f3eb81e1 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Thu, 12 Sep 2019 10:31:47 -0700 Subject: [PATCH] Fix receipt delivery --- .../src/Messages/OWSOutgoingReceiptManager.m | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/SignalServiceKit/src/Messages/OWSOutgoingReceiptManager.m b/SignalServiceKit/src/Messages/OWSOutgoingReceiptManager.m index 760aaa780f..bb5aa9c8b0 100644 --- a/SignalServiceKit/src/Messages/OWSOutgoingReceiptManager.m +++ b/SignalServiceKit/src/Messages/OWSOutgoingReceiptManager.m @@ -250,19 +250,19 @@ typedef NS_ENUM(NSUInteger, OWSReceiptType) { - (void)enqueueDeliveryReceiptForEnvelope:(SSKProtoEnvelope *)envelope { - [self enqueueReadReceiptForAddress:envelope.sourceAddress - timestamp:envelope.timestamp - receiptType:OWSReceiptType_Delivery]; + [self enqueueReceiptForAddress:envelope.sourceAddress + timestamp:envelope.timestamp + receiptType:OWSReceiptType_Delivery]; } - (void)enqueueReadReceiptForAddress:(SignalServiceAddress *)address timestamp:(uint64_t)timestamp { - [self enqueueReadReceiptForAddress:address timestamp:timestamp receiptType:OWSReceiptType_Read]; + [self enqueueReceiptForAddress:address timestamp:timestamp receiptType:OWSReceiptType_Read]; } -- (void)enqueueReadReceiptForAddress:(SignalServiceAddress *)address - timestamp:(uint64_t)timestamp - receiptType:(OWSReceiptType)receiptType +- (void)enqueueReceiptForAddress:(SignalServiceAddress *)address + timestamp:(uint64_t)timestamp + receiptType:(OWSReceiptType)receiptType { SDSKeyValueStore *store = [self storeForReceiptType:receiptType]; @@ -290,11 +290,15 @@ typedef NS_ENUM(NSUInteger, OWSReceiptType) { // Unexpectedly have entries both on phone number and UUID, defer to UUID if (oldUUIDTimestamps && oldPhoneNumberTimestamps) { + oldTimestamps = [oldUUIDTimestamps setByAddingObjectsFromSet:oldPhoneNumberTimestamps]; [store removeValueForKey:address.phoneNumber transaction:transaction]; // If we have timestamps only under phone number, but know the UUID, migrate them lazily } else if (oldPhoneNumberTimestamps && address.uuidString) { + oldTimestamps = oldPhoneNumberTimestamps; [store removeValueForKey:address.phoneNumber transaction:transaction]; + } else { + oldTimestamps = oldUUIDTimestamps ?: oldPhoneNumberTimestamps; } NSMutableSet *newTimestamps