Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent fd9ee4c9f3
commit c5f52cc0b9

@ -71,6 +71,7 @@ NS_ASSUME_NONNULL_BEGIN
TSOutgoingMessageRecipientState *_Nullable recipientState = TSOutgoingMessageRecipientState *_Nullable recipientState =
[self.message recipientStateForRecipientId:recipientId]; [self.message recipientStateForRecipientId:recipientId];
if (!recipientState) { if (!recipientState) {
OWSFailDebug(@"missing recipient state for: %@", recipientId);
continue; continue;
} }
if (recipientState.state != OWSOutgoingMessageRecipientStateSent) { if (recipientState.state != OWSOutgoingMessageRecipientStateSent) {

@ -739,6 +739,11 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
NSMutableDictionary<NSString *, TSOutgoingMessageRecipientState *> *recipientStateMap NSMutableDictionary<NSString *, TSOutgoingMessageRecipientState *> *recipientStateMap
= [NSMutableDictionary new]; = [NSMutableDictionary new];
for (NSString *recipientId in udRecipientIds) { for (NSString *recipientId in udRecipientIds) {
if (recipientStateMap[recipientId]) {
OWSFailDebug(
@"recipient appears more than once in recipient lists: %@", recipientId);
continue;
}
TSOutgoingMessageRecipientState *recipientState = TSOutgoingMessageRecipientState *recipientState =
[TSOutgoingMessageRecipientState new]; [TSOutgoingMessageRecipientState new];
recipientState.state = OWSOutgoingMessageRecipientStateSent; recipientState.state = OWSOutgoingMessageRecipientStateSent;
@ -746,6 +751,11 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
recipientStateMap[recipientId] = recipientState; recipientStateMap[recipientId] = recipientState;
} }
for (NSString *recipientId in nonUdRecipientIds) { for (NSString *recipientId in nonUdRecipientIds) {
if (recipientStateMap[recipientId]) {
OWSFailDebug(
@"recipient appears more than once in recipient lists: %@", recipientId);
continue;
}
TSOutgoingMessageRecipientState *recipientState = TSOutgoingMessageRecipientState *recipientState =
[TSOutgoingMessageRecipientState new]; [TSOutgoingMessageRecipientState new];
recipientState.state = OWSOutgoingMessageRecipientStateSent; recipientState.state = OWSOutgoingMessageRecipientStateSent;
@ -754,7 +764,9 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
} }
[message setRecipientStateMap:recipientStateMap]; [message setRecipientStateMap:recipientStateMap];
} else { } else {
// Otherwise, mark any "sending" recipients as "sent." // Otherwise assume this is a legacy message before UD was introduced, and mark
// any "sending" recipient as "sent". Note that this will apply to non-legacy
// messages with no recipients.
for (TSOutgoingMessageRecipientState *recipientState in message.recipientStateMap for (TSOutgoingMessageRecipientState *recipientState in message.recipientStateMap
.allValues) { .allValues) {
if (recipientState.state == OWSOutgoingMessageRecipientStateSending) { if (recipientState.state == OWSOutgoingMessageRecipientStateSending) {

Loading…
Cancel
Save