clang-format branch changes

This commit is contained in:
Michael Kirk 2018-10-12 09:49:50 -06:00 committed by Matthew Chen
parent b53cb9e616
commit 3e85c8c023
5 changed files with 54 additions and 27 deletions

View File

@ -22,14 +22,16 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSReceiptsForSenderMessage
+ (OWSReceiptsForSenderMessage *)deliveryReceiptsForSenderMessageWithThread:(nullable TSThread *)thread
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps {
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps
{
return [[OWSReceiptsForSenderMessage alloc] initWithThread:thread
messageTimestamps:messageTimestamps
receiptType:SSKProtoReceiptMessageTypeDelivery];
}
+ (OWSReceiptsForSenderMessage *)readReceiptsForSenderMessageWithThread:(nullable TSThread *)thread
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps {
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps
{
return [[OWSReceiptsForSenderMessage alloc] initWithThread:thread
messageTimestamps:messageTimestamps
receiptType:SSKProtoReceiptMessageTypeRead];
@ -37,7 +39,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithThread:(nullable TSThread *)thread
messageTimestamps:(NSArray<NSNumber *> *)messageTimestamps
receiptType:(SSKProtoReceiptMessageType)receiptType {
receiptType:(SSKProtoReceiptMessageType)receiptType
{
self = [super initOutgoingMessageWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread
messageBody:nil
@ -60,17 +63,20 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - TSOutgoingMessage overrides
- (BOOL)shouldSyncTranscript {
- (BOOL)shouldSyncTranscript
{
return NO;
}
- (BOOL)isSilent {
- (BOOL)isSilent
{
// Avoid "phantom messages" for "recipient read receipts".
return YES;
}
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient {
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient
{
OWSAssertDebug(recipient);
SSKProtoReceiptMessage *_Nullable receiptMessage = [self buildReceiptMessage:recipient.recipientId];
@ -91,7 +97,8 @@ NS_ASSUME_NONNULL_BEGIN
return contentData;
}
- (nullable SSKProtoReceiptMessage *)buildReceiptMessage:(NSString *)recipientId {
- (nullable SSKProtoReceiptMessage *)buildReceiptMessage:(NSString *)recipientId
{
SSKProtoReceiptMessageBuilder *builder = [SSKProtoReceiptMessage builderWithType:self.receiptType];
OWSAssertDebug(self.messageTimestamps.count > 0);
@ -110,11 +117,13 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - TSYapDatabaseObject overrides
- (BOOL)shouldBeSaved {
- (BOOL)shouldBeSaved
{
return NO;
}
- (NSString *)debugDescription {
- (NSString *)debugDescription
{
return [NSString
stringWithFormat:@"%@ with message timestamps: %lu", self.logTag, (unsigned long)self.messageTimestamps.count];
}

View File

@ -132,7 +132,8 @@ NS_ASSUME_NONNULL_BEGIN
return SSKEnvironment.shared.networkManager;
}
- (OWSOutgoingReceiptManager *)outgoingReceiptManager {
- (OWSOutgoingReceiptManager *)outgoingReceiptManager
{
OWSAssertDebug(SSKEnvironment.shared.outgoingReceiptManager);
return SSKEnvironment.shared.outgoingReceiptManager;

View File

@ -38,13 +38,15 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
@implementation OWSOutgoingReceiptManager
+ (instancetype)sharedManager {
+ (instancetype)sharedManager
{
OWSAssert(SSKEnvironment.shared.outgoingReceiptManager);
return SSKEnvironment.shared.outgoingReceiptManager;
}
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage {
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage
{
self = [super init];
if (!self) {
@ -70,13 +72,15 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
return self;
}
- (void)dealloc {
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - Dependencies
- (OWSMessageSender *)messageSender {
- (OWSMessageSender *)messageSender
{
OWSAssertDebug(SSKEnvironment.shared.messageSender);
return SSKEnvironment.shared.messageSender;
@ -84,7 +88,8 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
#pragma mark -
- (dispatch_queue_t)serialQueue {
- (dispatch_queue_t)serialQueue
{
static dispatch_queue_t _serialQueue;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
@ -95,7 +100,8 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
}
// Schedules a processing pass, unless one is already scheduled.
- (void)scheduleProcessing {
- (void)scheduleProcessing
{
OWSAssertDebug(AppReadiness.isAppReady);
dispatch_async(self.serialQueue, ^{
@ -109,7 +115,8 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
});
}
- (void)process {
- (void)process
{
OWSLogVerbose(@"Processing outbound receipts.");
if (!self.reachability.isReachable) {
@ -148,7 +155,8 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
[completionPromise retainUntilComplete];
}
- (NSArray<AnyPromise *> *)sendReceiptsForCollection:(NSString *)collection receiptType:(OWSReceiptType)receiptType {
- (NSArray<AnyPromise *> *)sendReceiptsForCollection:(NSString *)collection receiptType:(OWSReceiptType)receiptType
{
NSMutableDictionary<NSString *, NSSet<NSNumber *> *> *queuedReceiptMap = [NSMutableDictionary new];
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
@ -209,13 +217,15 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
return [sendPromises copy];
}
- (void)enqueueDeliveryReceiptForEnvelope:(SSKProtoEnvelope *)envelope {
- (void)enqueueDeliveryReceiptForEnvelope:(SSKProtoEnvelope *)envelope
{
[self enqueueReceiptWithRecipientId:envelope.source
timestamp:envelope.timestamp
collection:kOutgoingDeliveryReceiptManagerCollection];
}
- (void)enqueueReadReceiptForEnvelope:(NSString *)messageAuthorId timestamp:(uint64_t)timestamp {
- (void)enqueueReadReceiptForEnvelope:(NSString *)messageAuthorId timestamp:(uint64_t)timestamp
{
[self enqueueReceiptWithRecipientId:messageAuthorId
timestamp:timestamp
collection:kOutgoingReadReceiptManagerCollection];
@ -223,7 +233,8 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
- (void)enqueueReceiptWithRecipientId:(NSString *)recipientId
timestamp:(uint64_t)timestamp
collection:(NSString *)collection {
collection:(NSString *)collection
{
if (recipientId.length < 1) {
OWSFailDebug(@"Invalid recipient id.");
@ -249,7 +260,8 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
- (void)dequeueReceiptsWithRecipientId:(NSString *)recipientId
timestamps:(NSSet<NSNumber *> *)timestamps
collection:(NSString *)collection {
collection:(NSString *)collection
{
if (recipientId.length < 1) {
OWSFailDebug(@"Invalid recipient id.");
return;
@ -274,7 +286,8 @@ NSString *const kOutgoingReadReceiptManagerCollection = @"kOutgoingReadReceiptMa
});
}
- (void)reachabilityChanged {
- (void)reachabilityChanged
{
OWSAssertIsOnMainThread();
[self scheduleProcessing];

View File

@ -144,7 +144,8 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
return SSKEnvironment.shared.readReceiptManager;
}
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage {
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage
{
self = [super init];
if (!self) {
@ -172,13 +173,15 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
#pragma mark - Dependencies
- (OWSMessageSender *)messageSender {
- (OWSMessageSender *)messageSender
{
OWSAssertDebug(SSKEnvironment.shared.messageSender);
return SSKEnvironment.shared.messageSender;
}
- (OWSOutgoingReceiptManager *)outgoingReceiptManager {
- (OWSOutgoingReceiptManager *)outgoingReceiptManager
{
OWSAssertDebug(SSKEnvironment.shared.outgoingReceiptManager);
return SSKEnvironment.shared.outgoingReceiptManager;

View File

@ -62,7 +62,8 @@ static SSKEnvironment *sharedSSKEnvironment;
disappearingMessagesJob:(OWSDisappearingMessagesJob *)disappearingMessagesJob
contactDiscoveryService:(ContactDiscoveryService *)contactDiscoveryService
disappearingMessagesJob:(OWSReadReceiptManager *)readReceiptManager
contactDiscoveryService:(OWSOutgoingReceiptManager *)outgoingReceiptManager {
contactDiscoveryService:(OWSOutgoingReceiptManager *)outgoingReceiptManager
{
self = [super init];
if (!self) {
return self;