Rename to OWSOutgoingReceiptManager.

This commit is contained in:
Matthew Chen 2018-10-11 15:29:01 -04:00
parent 2b45a8348e
commit 010ce1f6c2
7 changed files with 35 additions and 35 deletions

View file

@ -14,12 +14,12 @@
#import <SignalServiceKit/OWSBackgroundTask.h>
#import <SignalServiceKit/OWSBatchMessageProcessor.h>
#import <SignalServiceKit/OWSBlockingManager.h>
#import <SignalServiceKit/OWSDeliveryReceiptManager.h>
#import <SignalServiceKit/OWSDisappearingMessagesJob.h>
#import <SignalServiceKit/OWSIdentityManager.h>
#import <SignalServiceKit/OWSMessageDecrypter.h>
#import <SignalServiceKit/OWSMessageManager.h>
#import <SignalServiceKit/OWSMessageReceiver.h>
#import <SignalServiceKit/OWSOutgoingReceiptManager.h>
#import <SignalServiceKit/OWSReadReceiptManager.h>
#import <SignalServiceKit/OWSStorage.h>
#import <SignalServiceKit/SSKEnvironment.h>
@ -72,8 +72,8 @@ NS_ASSUME_NONNULL_BEGIN
ContactDiscoveryService *contactDiscoveryService = [[ContactDiscoveryService alloc] initDefault];
OWSReadReceiptManager *readReceiptManager =
[[OWSReadReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
OWSDeliveryReceiptManager *deliveryReceiptManager =
[[OWSDeliveryReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
OWSOutgoingReceiptManager *outgoingReceiptManager =
[[OWSOutgoingReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
[Environment setShared:[[Environment alloc] initWithPreferences:preferences]];
@ -96,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
disappearingMessagesJob:disappearingMessagesJob
contactDiscoveryService:contactDiscoveryService
disappearingMessagesJob:readReceiptManager
contactDiscoveryService:deliveryReceiptManager]];
contactDiscoveryService:outgoingReceiptManager]];
appSpecificSingletonBlock();

View file

@ -12,7 +12,6 @@
#import "OWSBlockingManager.h"
#import "OWSCallMessageHandler.h"
#import "OWSContact.h"
#import "OWSDeliveryReceiptManager.h"
#import "OWSDevice.h"
#import "OWSDisappearingConfigurationUpdateInfoMessage.h"
#import "OWSDisappearingMessagesConfiguration.h"
@ -22,6 +21,7 @@
#import "OWSIncomingSentMessageTranscript.h"
#import "OWSMessageSender.h"
#import "OWSMessageUtils.h"
#import "OWSOutgoingReceiptManager.h"
#import "OWSPrimaryStorage+SessionStore.h"
#import "OWSPrimaryStorage.h"
#import "OWSReadReceiptManager.h"
@ -132,10 +132,10 @@ NS_ASSUME_NONNULL_BEGIN
return SSKEnvironment.shared.networkManager;
}
- (OWSDeliveryReceiptManager *)deliveryReceiptManager {
OWSAssertDebug(SSKEnvironment.shared.deliveryReceiptManager);
- (OWSOutgoingReceiptManager *)outgoingReceiptManager {
OWSAssertDebug(SSKEnvironment.shared.outgoingReceiptManager);
return SSKEnvironment.shared.deliveryReceiptManager;
return SSKEnvironment.shared.outgoingReceiptManager;
}
#pragma mark -
@ -503,7 +503,7 @@ NS_ASSUME_NONNULL_BEGIN
// Send delivery receipts for "valid data" messages received via UD.
BOOL wasReceivedByUD = envelope.type == SSKProtoEnvelopeTypeUnidentifiedSender;
if (wasReceivedByUD) {
[self.deliveryReceiptManager envelopeWasReceived:envelope];
[self.outgoingReceiptManager enqueueDeliveryReceiptForEnvelope:envelope];
}
}

View file

@ -7,13 +7,13 @@ NS_ASSUME_NONNULL_BEGIN
@class OWSPrimaryStorage;
@class SSKProtoEnvelope;
@interface OWSDeliveryReceiptManager : NSObject
@interface OWSOutgoingReceiptManager : NSObject
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage NS_DESIGNATED_INITIALIZER;
+ (instancetype)sharedManager;
- (void)envelopeWasReceived:(SSKProtoEnvelope *)envelope;
- (void)enqueueDeliveryReceiptForEnvelope:(SSKProtoEnvelope *)envelope;
@end

View file

@ -2,7 +2,7 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSDeliveryReceiptManager.h"
#import "OWSOutgoingReceiptManager.h"
#import "AppReadiness.h"
#import "OWSMessageSender.h"
#import "OWSPrimaryStorage.h"
@ -15,9 +15,9 @@
NS_ASSUME_NONNULL_BEGIN
NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCollection";
NSString *const kOutgoingReceiptManagerCollection = @"kOutgoingReceiptManagerCollection";
@interface OWSDeliveryReceiptManager ()
@interface OWSOutgoingReceiptManager ()
@property (nonatomic, readonly) YapDatabaseConnection *dbConnection;
@ -30,12 +30,12 @@ NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCol
#pragma mark -
@implementation OWSDeliveryReceiptManager
@implementation OWSOutgoingReceiptManager
+ (instancetype)sharedManager {
OWSAssert(SSKEnvironment.shared.deliveryReceiptManager);
OWSAssert(SSKEnvironment.shared.outgoingReceiptManager);
return SSKEnvironment.shared.deliveryReceiptManager;
return SSKEnvironment.shared.outgoingReceiptManager;
}
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage {
@ -114,7 +114,7 @@ NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCol
NSMutableDictionary<NSString *, NSSet<NSNumber *> *> *deliveryReceiptMap = [NSMutableDictionary new];
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
[transaction enumerateKeysAndObjectsInCollection:kDeliveryReceiptManagerCollection
[transaction enumerateKeysAndObjectsInCollection:kOutgoingReceiptManagerCollection
usingBlock:^(NSString *key, id object, BOOL *stop) {
NSString *recipientId = key;
NSSet<NSNumber *> *timestamps = object;
@ -179,7 +179,7 @@ NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCol
[completionPromise retainUntilComplete];
}
- (void)envelopeWasReceived:(SSKProtoEnvelope *)envelope {
- (void)enqueueDeliveryReceiptForEnvelope:(SSKProtoEnvelope *)envelope {
OWSLogVerbose(@"");
[self enqueueDeliveryReceiptWithRecipientId:envelope.source timestamp:envelope.timestamp];
@ -199,12 +199,12 @@ NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCol
dispatch_async(self.serialQueue, ^{
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
NSSet<NSNumber *> *_Nullable oldTimestamps = [transaction objectForKey:recipientId
inCollection:kDeliveryReceiptManagerCollection];
inCollection:kOutgoingReceiptManagerCollection];
NSMutableSet<NSNumber *> *newTimestamps
= (oldTimestamps ? [oldTimestamps mutableCopy] : [NSMutableSet new]);
[newTimestamps addObject:@(timestamp)];
[transaction setObject:newTimestamps forKey:recipientId inCollection:kDeliveryReceiptManagerCollection];
[transaction setObject:newTimestamps forKey:recipientId inCollection:kOutgoingReceiptManagerCollection];
}];
[self scheduleProcessing];
@ -223,15 +223,15 @@ NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCol
dispatch_async(self.serialQueue, ^{
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
NSSet<NSNumber *> *_Nullable oldTimestamps = [transaction objectForKey:recipientId
inCollection:kDeliveryReceiptManagerCollection];
inCollection:kOutgoingReceiptManagerCollection];
NSMutableSet<NSNumber *> *newTimestamps
= (oldTimestamps ? [oldTimestamps mutableCopy] : [NSMutableSet new]);
[newTimestamps minusSet:timestamps];
if (newTimestamps.count > 0) {
[transaction setObject:newTimestamps forKey:recipientId inCollection:kDeliveryReceiptManagerCollection];
[transaction setObject:newTimestamps forKey:recipientId inCollection:kOutgoingReceiptManagerCollection];
} else {
[transaction removeObjectForKey:recipientId inCollection:kDeliveryReceiptManagerCollection];
[transaction removeObjectForKey:recipientId inCollection:kOutgoingReceiptManagerCollection];
}
}];
});

View file

@ -9,13 +9,13 @@ NS_ASSUME_NONNULL_BEGIN
@class OWS2FAManager;
@class OWSBatchMessageProcessor;
@class OWSBlockingManager;
@class OWSDeliveryReceiptManager;
@class OWSDisappearingMessagesJob;
@class OWSIdentityManager;
@class OWSMessageDecrypter;
@class OWSMessageManager;
@class OWSMessageReceiver;
@class OWSMessageSender;
@class OWSOutgoingReceiptManager;
@class OWSPrimaryStorage;
@class OWSReadReceiptManager;
@class TSAccountManager;
@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
disappearingMessagesJob:(OWSDisappearingMessagesJob *)disappearingMessagesJob
contactDiscoveryService:(ContactDiscoveryService *)contactDiscoveryService
disappearingMessagesJob:(OWSReadReceiptManager *)readReceiptManager
contactDiscoveryService:(OWSDeliveryReceiptManager *)deliveryReceiptManager NS_DESIGNATED_INITIALIZER;
contactDiscoveryService:(OWSOutgoingReceiptManager *)outgoingReceiptManager NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) OWSDisappearingMessagesJob *disappearingMessagesJob;
@property (nonatomic, readonly) ContactDiscoveryService *contactDiscoveryService;
@property (nonatomic, readonly) OWSReadReceiptManager *readReceiptManager;
@property (nonatomic, readonly) OWSDeliveryReceiptManager *deliveryReceiptManager;
@property (nonatomic, readonly) OWSOutgoingReceiptManager *outgoingReceiptManager;
// This property is configured after Environment is created.
@property (atomic, nullable) id<OWSCallMessageHandler> callMessageHandler;

View file

@ -31,7 +31,7 @@ static SSKEnvironment *sharedSSKEnvironment;
@property (nonatomic) OWSDisappearingMessagesJob *disappearingMessagesJob;
@property (nonatomic) ContactDiscoveryService *contactDiscoveryService;
@property (nonatomic) OWSReadReceiptManager *readReceiptManager;
@property (nonatomic) OWSDeliveryReceiptManager *deliveryReceiptManager;
@property (nonatomic) OWSOutgoingReceiptManager *outgoingReceiptManager;
@end
@ -62,7 +62,7 @@ static SSKEnvironment *sharedSSKEnvironment;
disappearingMessagesJob:(OWSDisappearingMessagesJob *)disappearingMessagesJob
contactDiscoveryService:(ContactDiscoveryService *)contactDiscoveryService
disappearingMessagesJob:(OWSReadReceiptManager *)readReceiptManager
contactDiscoveryService:(OWSDeliveryReceiptManager *)deliveryReceiptManager {
contactDiscoveryService:(OWSOutgoingReceiptManager *)outgoingReceiptManager {
self = [super init];
if (!self) {
return self;
@ -87,7 +87,7 @@ static SSKEnvironment *sharedSSKEnvironment;
OWSAssertDebug(disappearingMessagesJob);
OWSAssertDebug(contactDiscoveryService);
OWSAssertDebug(readReceiptManager);
OWSAssertDebug(deliveryReceiptManager);
OWSAssertDebug(outgoingReceiptManager);
_contactsManager = contactsManager;
_messageSender = messageSender;
@ -108,7 +108,7 @@ static SSKEnvironment *sharedSSKEnvironment;
_disappearingMessagesJob = disappearingMessagesJob;
_contactDiscoveryService = contactDiscoveryService;
_readReceiptManager = readReceiptManager;
_deliveryReceiptManager = deliveryReceiptManager;
_outgoingReceiptManager = outgoingReceiptManager;
return self;
}

View file

@ -7,7 +7,6 @@
#import "OWS2FAManager.h"
#import "OWSBatchMessageProcessor.h"
#import "OWSBlockingManager.h"
#import "OWSDeliveryReceiptManager.h"
#import "OWSDisappearingMessagesJob.h"
#import "OWSFakeCallMessageHandler.h"
#import "OWSFakeContactsManager.h"
@ -20,6 +19,7 @@
#import "OWSMessageDecrypter.h"
#import "OWSMessageManager.h"
#import "OWSMessageReceiver.h"
#import "OWSOutgoingReceiptManager.h"
#import "OWSPrimaryStorage.h"
#import "OWSReadReceiptManager.h"
#import "TSAccountManager.h"
@ -70,8 +70,8 @@ NS_ASSUME_NONNULL_BEGIN
[[OWSDisappearingMessagesJob alloc] initWithPrimaryStorage:primaryStorage];
ContactDiscoveryService *contactDiscoveryService = [[ContactDiscoveryService alloc] initDefault];
OWSReadReceiptManager *readReceiptManager = [[OWSReadReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
OWSDeliveryReceiptManager *deliveryReceiptManager =
[[OWSDeliveryReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
OWSOutgoingReceiptManager *outgoingReceiptManager =
[[OWSOutgoingReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
self = [super initWithContactsManager:contactsManager
messageSender:messageSender
@ -92,7 +92,7 @@ NS_ASSUME_NONNULL_BEGIN
disappearingMessagesJob:disappearingMessagesJob
contactDiscoveryService:contactDiscoveryService
disappearingMessagesJob:readReceiptManager
contactDiscoveryService:deliveryReceiptManager];
contactDiscoveryService:outgoingReceiptManager];
if (!self) {
return nil;
}