From a9e7c5e8798a9cdb6a653934ef5f74668a03880b Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 18 Apr 2018 11:21:16 -0400 Subject: [PATCH] Cleanup: simplify migration, remove unused code // FREEBIE --- .../src/Devices/OWSLinkedDeviceReadReceipt.m | 25 ++++++++----------- .../src/Messages/OWSDisappearingMessagesJob.h | 1 - .../src/Messages/OWSDisappearingMessagesJob.m | 22 ---------------- 3 files changed, 10 insertions(+), 38 deletions(-) diff --git a/SignalServiceKit/src/Devices/OWSLinkedDeviceReadReceipt.m b/SignalServiceKit/src/Devices/OWSLinkedDeviceReadReceipt.m index c7dacaa9b..7178a38d4 100644 --- a/SignalServiceKit/src/Devices/OWSLinkedDeviceReadReceipt.m +++ b/SignalServiceKit/src/Devices/OWSLinkedDeviceReadReceipt.m @@ -6,13 +6,6 @@ NS_ASSUME_NONNULL_BEGIN -@interface OWSLinkedDeviceReadReceipt () - -// FIXME remove this `timestamp` property and migrate in initWithCoder. -@property (nonatomic, readonly) uint64_t timestamp; - -@end - @implementation OWSLinkedDeviceReadReceipt - (instancetype)initWithSenderId:(NSString *)senderId @@ -42,18 +35,20 @@ NS_ASSUME_NONNULL_BEGIN return self; } + // renamed timestamp -> messageIdTimestamp if (!_messageIdTimestamp) { - // FIXME to remove this legacy `timestamp` property, we need to figure out exactly how MTL encodes uint64_t. - // e.g. can we just do something like: `((NSNumber *)[coder decodeObjectForKey:@"timestamp"]).unsignedLongLong` - _messageIdTimestamp = _timestamp; + NSNumber *_Nullable legacyTimestamp = (NSNumber *)[coder decodeObjectForKey:@"timestamp"]; + OWSAssert(legacyTimestamp.unsignedLongLongValue > 0); + _messageIdTimestamp = legacyTimestamp.unsignedLongLongValue; } - // For legacy early LinkedDeviceReadReceipts, before we were tracking read time, we assume the message was read as - // soon as it was sent. This is always going to be at least a little earlier than it was actually read, but we have - // nothing better to choose, and by the very fact that we're receiving a read receipt, we have good reason to - // believe they read the message on the other device. + // For legacy objects, before we were tracking read time, use the original messages "sent" timestamp + // as the local read time. This will always be at least a little bit earlier than the message was + // actually read, but it's the safer assumption. At worst we'll delete the message from this device + // earlier than the user expects, but this shouldn't be terrible because we know they've read the + // message on the other device. Keep in mind this *only* affects "early" read receipts. if (_readTimestamp == 0) { - _readTimestamp = _timestamp; + _readTimestamp = _messageIdTimestamp; } return self; diff --git a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.h b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.h index dd7ef9ec4..032c61add 100644 --- a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.h +++ b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.h @@ -17,7 +17,6 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init NS_UNAVAILABLE; -//+ (void)setExpirationsForThread:(TSThread *)thread; - (void)startAnyExpirationForMessage:(TSMessage *)message expirationStartedAt:(uint64_t)expirationStartedAt transaction:(YapDatabaseReadWriteTransaction *_Nonnull)transaction; diff --git a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m index 4c92811b3..e015900cb 100644 --- a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m +++ b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m @@ -210,28 +210,6 @@ void AssertIsOnDisappearingMessagesQueue() }]; } -//- (void)setExpirationsForThread:(TSThread *)thread transaction:(YapDatabaseReadWriteTransaction *)transaction -//{ -// OWSBackgroundTask *_Nullable backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__]; -// -// uint64_t now = [NSDate ows_millisecondTimeStamp]; -// [self.disappearingMessagesFinder -// enumerateUnstartedExpiringMessagesInThread:thread -// block:^(TSMessage *_Nonnull message) { -// DDLogWarn(@"%@ Starting expiring message which should have already " -// @"been started.", -// self.logTag); -// // specify "now" in case D.M. have since been disabled, but we have -// // existing unstarted expiring messages that still need to expire. -// [self setExpirationForMessage:message -// expirationStartedAt:now -// transaction:transaction]; -// } -// transaction:transaction]; -// -// backgroundTask = nil; -//} - - (void)becomeConsistentWithConfigurationForMessage:(TSMessage *)message contactsManager:(id)contactsManager transaction:(YapDatabaseReadWriteTransaction *)transaction