Merge branch 'mkirk/remove-unnecessary-notifications'

pull/1/head
Michael Kirk 8 years ago
commit 33a2b05dca

@ -5,7 +5,6 @@
#import "TSErrorMessage.h"
#import "ContactsManagerProtocol.h"
#import "NSDate+millisecondTimeStamp.h"
#import "NotificationsProtocol.h"
#import "TSContactThread.h"
#import "TSErrorMessage_privateConstructor.h"
#import "TSMessagesManager.h"
@ -46,15 +45,6 @@ NS_ASSUME_NONNULL_BEGIN
_errorType = errorMessageType;
_recipientId = recipientId;
// TODO: Move this out of model class.
//
// For now, dispatch async to ensure we're not inside a transaction
// and thereby avoid deadlock.
TSErrorMessage *errorMessage = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[TextSecureKitEnv sharedEnv].notificationsManager notifyUserForErrorMessage:errorMessage inThread:thread];
});
return self;
}

@ -333,6 +333,7 @@ NS_ASSUME_NONNULL_BEGIN
TSErrorMessage *errorMessage =
[TSErrorMessage missingSessionWithEnvelope:messageEnvelope withTransaction:transaction];
[errorMessage saveWithTransaction:transaction];
[self notififyForErrorMessage:errorMessage withEnvelope:messageEnvelope];
}];
DDLogError(@"Skipping message envelope for unknown session.");
completion(nil);
@ -974,9 +975,9 @@ NS_ASSUME_NONNULL_BEGIN
exception.description,
exception.name,
exception.reason);
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
TSErrorMessage *errorMessage;
__block TSErrorMessage *errorMessage;
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
if ([exception.name isEqualToString:NoSessionException]) {
errorMessage = [TSErrorMessage missingSessionWithEnvelope:envelope withTransaction:transaction];
} else if ([exception.name isEqualToString:InvalidKeyException]) {
@ -997,6 +998,16 @@ NS_ASSUME_NONNULL_BEGIN
[errorMessage saveWithTransaction:transaction];
}];
if (errorMessage != nil) {
[self notififyForErrorMessage:errorMessage withEnvelope:envelope];
}
}
- (void)notififyForErrorMessage:(TSErrorMessage *)errorMessage withEnvelope:(OWSSignalServiceProtosEnvelope *)envelope
{
TSThread *contactThread = [TSContactThread getOrCreateThreadWithContactId:envelope.source];
[[TextSecureKitEnv sharedEnv].notificationsManager notifyUserForErrorMessage:errorMessage inThread:contactThread];
}
#pragma mark - helpers

@ -3,6 +3,8 @@
//
#import "NSDate+millisecondTimeStamp.h"
#import "NotificationsProtocol.h"
#import "OWSRecipientIdentity.h"
#import "TSAccountManager.h"
#import "TSContactThread.h"
#import "TSErrorMessage.h"
@ -11,7 +13,6 @@
#import "TSStorageManager+IdentityKeyStore.h"
#import "TSStorageManager+SessionStore.h"
#import "TextSecureKitEnv.h"
#import "OWSRecipientIdentity.h"
#import <25519/Curve25519.h>
NS_ASSUME_NONNULL_BEGIN
@ -266,7 +267,11 @@ const NSTimeInterval kIdentityKeyStoreNonBlockingSecondsThreshold = 5.0;
TSContactThread *contactThread = [TSContactThread getOrCreateThreadWithContactId:recipientId];
OWSAssert(contactThread != nil);
[[TSErrorMessage nonblockingIdentityChangeInThread:contactThread recipientId:recipientId] save];
TSErrorMessage *errorMessage =
[TSErrorMessage nonblockingIdentityChangeInThread:contactThread recipientId:recipientId];
[errorMessage save];
[[TextSecureKitEnv sharedEnv].notificationsManager notifyUserForErrorMessage:errorMessage inThread:contactThread];
for (TSGroupThread *groupThread in [TSGroupThread groupThreadsWithRecipientId:recipientId]) {
[[TSErrorMessage nonblockingIdentityChangeInThread:groupThread recipientId:recipientId] save];

Loading…
Cancel
Save