Partial Revert of 'Mark messages locally as read but wait to send receipts until the message request is approved.'
Reverting all the OutgoingReceiptManager logic changes - but keeping some ancillary changes.
This commit is contained in:
parent
72718c62bb
commit
6a892c4150
@ -3670,6 +3670,11 @@ typedef enum : NSUInteger {
|
||||
|
||||
- (void)markVisibleMessagesAsRead
|
||||
{
|
||||
// Don't mark messages as read until the message request has been processed
|
||||
if (self.messageRequestView) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.presentedViewController) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,11 +171,6 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
||||
return SSKEnvironment.shared.syncManager;
|
||||
}
|
||||
|
||||
- (OWSOutgoingReceiptManager *)outgoingReceiptManager
|
||||
{
|
||||
return SSKEnvironment.shared.outgoingReceiptManager;
|
||||
}
|
||||
|
||||
- (id<OWSUDManager>)udManager
|
||||
{
|
||||
OWSAssertDebug(SSKEnvironment.shared.udManager);
|
||||
@ -961,9 +956,6 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
||||
[OWSStorageServiceManager.shared recordPendingUpdatesWithUpdatedAddresses:addressesToRemove.allObjects];
|
||||
}
|
||||
|
||||
// If we've updated our whitelist, there may be new read receipts ready to process.
|
||||
[self.outgoingReceiptManager process];
|
||||
|
||||
for (SignalServiceAddress *address in addressesToRemove) {
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kNSNotificationName_ProfileWhitelistDidChange
|
||||
@ -1000,9 +992,6 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
||||
[OWSStorageServiceManager.shared recordPendingUpdatesWithUpdatedAddresses:addressesToAdd.allObjects];
|
||||
}
|
||||
|
||||
// If we've updated our whitelist, there may be new read receipts ready to process.
|
||||
[self.outgoingReceiptManager process];
|
||||
|
||||
for (SignalServiceAddress *address in addressesToAdd) {
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kNSNotificationName_ProfileWhitelistDidChange
|
||||
@ -1117,9 +1106,6 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
||||
[OWSStorageServiceManager.shared recordPendingUpdatesWithUpdatedGroupIds:@[ groupId ]];
|
||||
}
|
||||
|
||||
// If we've updated our whitelist, there may be new read receipts ready to process.
|
||||
[self.outgoingReceiptManager process];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationNameAsync:kNSNotificationName_ProfileWhitelistDidChange
|
||||
object:nil
|
||||
userInfo:@ {
|
||||
@ -1144,9 +1130,6 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
||||
[OWSStorageServiceManager.shared recordPendingUpdatesWithUpdatedGroupIds:@[ groupId ]];
|
||||
}
|
||||
|
||||
// If we've updated our whitelist, there may be new read receipts ready to process.
|
||||
[self.outgoingReceiptManager process];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationNameAsync:kNSNotificationName_ProfileWhitelistDidChange
|
||||
object:nil
|
||||
userInfo:@ {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@ -18,8 +18,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (void)process;
|
||||
|
||||
- (void)enqueueDeliveryReceiptForEnvelope:(SSKProtoEnvelope *)envelope
|
||||
transaction:(SDSAnyWriteTransaction *)transaction;
|
||||
|
||||
|
||||
@ -184,38 +184,8 @@ typedef NS_ENUM(NSUInteger, OWSReceiptType) {
|
||||
[store enumerateKeysAndObjectsWithTransaction:transaction
|
||||
block:^(NSString *key, id object, BOOL *stop) {
|
||||
NSString *recipientId = key;
|
||||
NSMutableSet<NSNumber *> *timestamps = [object mutableCopy];
|
||||
|
||||
// Filter the pending receipts to remove any for threads that have a
|
||||
// pending message request. We wait to send read receipts until a
|
||||
// message request is approved.
|
||||
if (receiptType == OWSReceiptType_Read && RemoteConfig.messageRequests) {
|
||||
SignalServiceAddress *address =
|
||||
[self addressForIdentifier:recipientId];
|
||||
if (!address.isValid) {
|
||||
OWSFailDebug(@"Unexpected identifier.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (NSNumber *timestamp in [timestamps copy]) {
|
||||
TSThread *_Nullable messageThread = [InteractionFinder
|
||||
findThreadForInteractionWithTimestamp:
|
||||
[timestamp unsignedLongLongValue]
|
||||
author:address
|
||||
transaction:transaction];
|
||||
|
||||
if (messageThread &&
|
||||
[AnyThreadFinder
|
||||
hasPendingMessageRequestWithThread:messageThread
|
||||
transaction:transaction]) {
|
||||
[timestamps removeObject:timestamp];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (timestamps.count > 0) {
|
||||
queuedReceiptMap[recipientId] = [timestamps copy];
|
||||
}
|
||||
NSSet<NSNumber *> *timestamps = object;
|
||||
queuedReceiptMap[recipientId] = [timestamps copy];
|
||||
}];
|
||||
}];
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -228,55 +228,6 @@ public class InteractionFinder: NSObject, InteractionFinderAdapter {
|
||||
return nil
|
||||
}
|
||||
|
||||
@objc
|
||||
public class func findThread(
|
||||
forInteractionWithTimestamp timestamp: UInt64,
|
||||
author: SignalServiceAddress,
|
||||
transaction: SDSAnyReadTransaction
|
||||
) -> TSThread? {
|
||||
guard timestamp > 0 else {
|
||||
owsFailDebug("invalid timestamp: \(timestamp)")
|
||||
return nil
|
||||
}
|
||||
|
||||
guard author.isValid else {
|
||||
owsFailDebug("Invalid author \(author)")
|
||||
return nil
|
||||
}
|
||||
|
||||
let interactions: [TSInteraction]
|
||||
|
||||
do {
|
||||
interactions = try InteractionFinder.interactions(
|
||||
withTimestamp: timestamp,
|
||||
filter: { $0 is TSMessage },
|
||||
transaction: transaction
|
||||
)
|
||||
} catch {
|
||||
owsFailDebug("Error loading interactions \(error.localizedDescription)")
|
||||
return nil
|
||||
}
|
||||
|
||||
for interaction in interactions {
|
||||
guard let message = interaction as? TSMessage else {
|
||||
owsFailDebug("received unexpected non-message interaction")
|
||||
continue
|
||||
}
|
||||
|
||||
if let incomingMessage = message as? TSIncomingMessage,
|
||||
incomingMessage.authorAddress.isEqualToAddress(author) {
|
||||
return incomingMessage.thread(transaction: transaction)
|
||||
}
|
||||
|
||||
if let outgoingMessage = message as? TSOutgoingMessage,
|
||||
author.isLocalAddress {
|
||||
return outgoingMessage.thread(transaction: transaction)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MARK: - instance methods
|
||||
|
||||
@objc
|
||||
|
||||
Loading…
Reference in New Issue
Block a user