PR Feedback

This commit is contained in:
Nora Trapp 2020-10-09 10:18:31 -07:00
parent 23d1a39677
commit 548ce607d1
3 changed files with 20 additions and 2 deletions

View File

@ -66,10 +66,12 @@ NS_ASSUME_NONNULL_BEGIN
[super anyUpdateOutgoingMessageWithTransaction:transaction block:block];
// Some older outgoing delete messages didn't store the deleted message's unique id.
// We want to mirror our sending state onto the original message, so it shows up
// within the conversation.
if (self.messageUniqueId) {
TSOutgoingMessage *deletedMessage = [TSOutgoingMessage anyFetchOutgoingMessageWithUniqueId:self.messageUniqueId
transaction:transaction];
[deletedMessage anyUpdateOutgoingMessageWithTransaction:transaction block:block];
[deletedMessage updateWithRecipientAddressStates:self.recipientAddressStates transaction:transaction];
}
}

View File

@ -874,6 +874,12 @@ NSUInteger const TSOutgoingMessageSchemaVersion = 1;
OWSAssertDebug(recipientAddress.isValid);
OWSAssertDebug(transaction);
// Ignore receipts for messages that have been deleted.
// They are no longer relevant to this message.
if (self.wasRemotelyDeleted) {
return;
}
// If delivery notification doesn't include timestamp, use "now" as an estimate.
if (!deliveryTimestamp) {
deliveryTimestamp = @([NSDate ows_millisecondTimeStamp]);
@ -904,6 +910,12 @@ NSUInteger const TSOutgoingMessageSchemaVersion = 1;
OWSAssertDebug(recipientAddress.isValid);
OWSAssertDebug(transaction);
// Ignore receipts for messages that have been deleted.
// They are no longer relevant to this message.
if (self.wasRemotelyDeleted) {
return;
}
[self anyUpdateOutgoingMessageWithTransaction:transaction
block:^(TSOutgoingMessage *message) {
TSOutgoingMessageRecipientState *_Nullable recipientState

View File

@ -254,7 +254,11 @@ NSError *SSKEnsureError(NSError *_Nullable error, OWSErrorCode fallbackCode, NSS
[self.databaseStorage readWithBlock:^(SDSAnyReadTransaction *transaction) {
latestCopy = [TSInteraction anyFetchWithUniqueId:self.message.uniqueId transaction:transaction];
}];
if (self.message.shouldBeSaved && latestCopy == nil) {
BOOL messageWasRemotelyDeleted = NO;
if ([latestCopy isKindOfClass:[TSOutgoingMessage class]]) {
messageWasRemotelyDeleted = ((TSOutgoingMessage *)latestCopy).wasRemotelyDeleted;
}
if ((self.message.shouldBeSaved && latestCopy == nil) || messageWasRemotelyDeleted) {
OWSLogInfo(@"aborting message send; message deleted.");
NSError *error = OWSErrorWithCodeDescription(
OWSErrorCodeMessageDeletedBeforeSent, @"Message was deleted before it could be sent.");