Don't enqueue sender read receipts from self-sent messages

These messages are always already read.

Reminder, there are two types of read receipts:

1. One informs our linked devices that we've read a message on another
device.
2. The other informs the sender that we've read their message.

This change is about the latter, we'll continue to send the former to
ourself.

The proximate cause for this change was a failing assert in
OWSMessageSender#handleSendToMyself:(TSOutgoingMessage *)outgoingMessage

The assert was failing because we were sending a message to ourself
which had no body or attachment (the sender-read receipt). Rather than
filtering them out from the message sender, we should never ask the
message sender to do nonsense work (send a senderReadReceipt to ourself)

// FREEBIE
This commit is contained in:
Michael Kirk 2018-02-23 11:19:21 -05:00
parent c66fb70b2f
commit b79244affa

View file

@ -12,6 +12,7 @@
#import "OWSSignalServiceProtos.pb.h"
#import "OWSStorage.h"
#import "OWSSyncConfigurationMessage.h"
#import "TSAccountManager.h"
#import "TSContactThread.h"
#import "TSDatabaseView.h"
#import "TSIncomingMessage.h"
@ -318,6 +319,11 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
self.toLinkedDevicesReadReceiptMap[threadUniqueId] = newReadReceipt;
}
if ([message.messageAuthorId isEqualToString:[TSAccountManager localNumber]]) {
DDLogVerbose(@"%@ Ignoring read receipt for self-sender.", self.logTag);
return;
}
if ([self areReadReceiptsEnabled]) {
DDLogVerbose(@"%@ Enqueuing read receipt for sender.", self.logTag);
NSMutableSet<NSNumber *> *_Nullable timestamps = self.toSenderReadReceiptMap[messageAuthorId];