Respond to CR.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-09-27 14:19:26 -04:00
parent aa7329013d
commit a4d285f50d
4 changed files with 28 additions and 20 deletions

View File

@ -299,7 +299,7 @@ class MessageMetadataViewController: OWSViewController {
let deliveryDate = NSDate.ows_date(withMillisecondsSince1970:deliveryTimestamp.uint64Value)
return String(format:NSLocalizedString("MESSAGE_STATUS_DELIVERED_WITH_TIMESTAMP_FORMAT",
comment: "message status for messages delivered to the recipient. Embeds: {{the date and time the message was delivered}}."),
dateFormatter.string(from:deliveryDate))
MessageMetadataViewController.dateFormatter.string(from:deliveryDate))
}
if message.wasDelivered {

View File

@ -174,7 +174,10 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
- (void)updateWithHasSyncedTranscript:(BOOL)hasSyncedTranscript;
- (void)updateWithCustomMessage:(NSString *)customMessage transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)updateWithCustomMessage:(NSString *)customMessage;
// deliveryTimestamp is an optional parameter.
// deliveryTimestamp is an optional parameter, since legacy
// delivery receipts don't have a "delivery timestamp". Those
// messages repurpose the "timestamp" field to indicate when the
// corresponding message was originally sent.
- (void)updateWithDeliveredToRecipientId:(NSString *)recipientId
deliveryTimestamp:(NSNumber *_Nullable)deliveryTimestamp
transaction:(YapDatabaseReadWriteTransaction *)transaction;

View File

@ -325,7 +325,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
? [message.recipientDeliveryMap mutableCopy]
: [NSMutableDictionary new]);
recipientDeliveryMap[recipientId] = deliveryTimestamp;
message.recipientDeliveryMap = recipientDeliveryMap;
message.recipientDeliveryMap = [recipientDeliveryMap copy];
}
[message setWasDelivered:YES];
@ -431,7 +431,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
= (message.recipientReadMap ? [message.recipientReadMap mutableCopy]
: [NSMutableDictionary new]);
recipientReadMap[recipientId] = @(readTimestamp);
message.recipientReadMap = recipientReadMap;
message.recipientReadMap = [recipientReadMap copy];
}];
}

View File

@ -187,19 +187,22 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(transaction);
// Old-style delivery notices don't include a "delivery timestamp".
[self processDeliveryReceipts:envelope.source
sentTimestamps:@[
@(envelope.timestamp),
]
deliveryTimestamp:nil
transaction:transaction];
[self processDeliveryReceiptsFromRecipientId:envelope.source
sentTimestamps:@[
@(envelope.timestamp),
]
deliveryTimestamp:nil
transaction:transaction];
}
// deliveryTimestamp is an optional parameter.
- (void)processDeliveryReceipts:(NSString *)recipientId
sentTimestamps:(NSArray<NSNumber *> *)sentTimestamps
deliveryTimestamp:(NSNumber *_Nullable)deliveryTimestamp
transaction:(YapDatabaseReadWriteTransaction *)transaction
// deliveryTimestamp is an optional parameter, since legacy
// delivery receipts don't have a "delivery timestamp". Those
// messages repurpose the "timestamp" field to indicate when the
// corresponding message was originally sent.
- (void)processDeliveryReceiptsFromRecipientId:(NSString *)recipientId
sentTimestamps:(NSArray<NSNumber *> *)sentTimestamps
deliveryTimestamp:(NSNumber *_Nullable)deliveryTimestamp
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(recipientId);
OWSAssert(sentTimestamps);
@ -213,8 +216,10 @@ NS_ASSUME_NONNULL_BEGIN
ofClass:[TSOutgoingMessage class]
withTransaction:transaction];
if (messages.count < 1) {
// Desktop currently sends delivery receipts for "unpersisted" messages
// The service sends delivery receipts for "unpersisted" messages
// like group updates, so these errors are expected to a certain extent.
//
// TODO: persist "early" delivery receipts.
DDLogInfo(@"%@ Missing message for delivery receipt: %llu", self.tag, timestamp);
} else {
if (messages.count > 1) {
@ -379,10 +384,10 @@ NS_ASSUME_NONNULL_BEGIN
switch (receiptMessage.type) {
case OWSSignalServiceProtosReceiptMessageTypeDelivery:
DDLogVerbose(@"%@ Processing receipt message with delivery receipts.", self.tag);
[self processDeliveryReceipts:envelope.source
sentTimestamps:sentTimestamps
deliveryTimestamp:@(envelope.timestamp)
transaction:transaction];
[self processDeliveryReceiptsFromRecipientId:envelope.source
sentTimestamps:sentTimestamps
deliveryTimestamp:@(envelope.timestamp)
transaction:transaction];
return;
case OWSSignalServiceProtosReceiptMessageTypeRead:
DDLogVerbose(@"%@ Processing receipt message with read receipts.", self.tag);