diff --git a/src/Contacts/SignalRecipient.h b/src/Contacts/SignalRecipient.h index 9509fbb88..7741808b6 100644 --- a/src/Contacts/SignalRecipient.h +++ b/src/Contacts/SignalRecipient.h @@ -1,17 +1,14 @@ -// -// TSRecipient.h -// TextSecureKit -// // Created by Frederic Jacobs on 17/11/14. // Copyright (c) 2014 Open Whisper Systems. All rights reserved. -// #import "TSYapDatabaseObject.h" +NS_ASSUME_NONNULL_BEGIN + @interface SignalRecipient : TSYapDatabaseObject - (instancetype)initWithTextSecureIdentifier:(NSString *)textSecureIdentifier - relay:(NSString *)relay + relay:(nullable NSString *)relay supportsVoice:(BOOL)voiceCapable; + (instancetype)recipientWithTextSecureIdentifier:(NSString *)textSecureIdentifier @@ -21,8 +18,10 @@ - (void)removeDevices:(NSSet *)set; -@property (nonatomic) NSString *relay; +@property (nonatomic, nullable) NSString *relay; @property (nonatomic, retain) NSMutableOrderedSet *devices; @property BOOL supportsVoice; @end + +NS_ASSUME_NONNULL_END diff --git a/src/Contacts/SignalRecipient.m b/src/Contacts/SignalRecipient.m index 0a7a7f349..4cf2b28d1 100644 --- a/src/Contacts/SignalRecipient.m +++ b/src/Contacts/SignalRecipient.m @@ -1,14 +1,11 @@ -// -// TSRecipient.m -// TextSecureKit -// // Created by Frederic Jacobs on 17/11/14. // Copyright (c) 2014 Open Whisper Systems. All rights reserved. -// #import "SignalRecipient.h" #import "TSStorageManager+IdentityKeyStore.h" +NS_ASSUME_NONNULL_BEGIN + @implementation SignalRecipient + (NSString *)collection { @@ -16,16 +13,18 @@ } - (instancetype)initWithTextSecureIdentifier:(NSString *)textSecureIdentifier - relay:(NSString *)relay - supportsVoice:(BOOL)voiceCapable { + relay:(nullable NSString *)relay + supportsVoice:(BOOL)voiceCapable +{ self = [super initWithUniqueId:textSecureIdentifier]; - - if (self) { - _devices = [NSMutableOrderedSet orderedSetWithObject:[NSNumber numberWithInt:1]]; - _relay = relay; - _supportsVoice = voiceCapable; + if (!self) { + return self; } + _devices = [NSMutableOrderedSet orderedSetWithObject:[NSNumber numberWithInt:1]]; + _relay = [relay isEqualToString:@""] ? nil : relay; + _supportsVoice = voiceCapable; + return self; } @@ -55,3 +54,5 @@ } @end + +NS_ASSUME_NONNULL_END diff --git a/src/Contacts/Threads/TSContactThread.h b/src/Contacts/Threads/TSContactThread.h index bb78c08c9..51c310136 100644 --- a/src/Contacts/Threads/TSContactThread.h +++ b/src/Contacts/Threads/TSContactThread.h @@ -1,17 +1,9 @@ -// -// TSContactThread.h -// TextSecureKit -// // Created by Frederic Jacobs on 16/11/14. // Copyright (c) 2014 Open Whisper Systems. All rights reserved. -// -#import - -#import "SignalRecipient.h" #import "TSThread.h" -@class OWSSignalServiceProtosEnvelope; +NS_ASSUME_NONNULL_BEGIN @interface TSContactThread : TSThread @@ -20,8 +12,12 @@ + (instancetype)getOrCreateThreadWithContactId:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction - envelope:(OWSSignalServiceProtosEnvelope *)envelope; + relay:(nullable NSString *)relay; + +- (NSString *)contactIdentifier; - (NSString *)contactIdentifier; @end + +NS_ASSUME_NONNULL_END diff --git a/src/Contacts/Threads/TSContactThread.m b/src/Contacts/Threads/TSContactThread.m index 80c7ba2c9..261d13632 100644 --- a/src/Contacts/Threads/TSContactThread.m +++ b/src/Contacts/Threads/TSContactThread.m @@ -3,10 +3,11 @@ #import "TSContactThread.h" #import "ContactsUpdater.h" -#import "OWSSignalServiceProtos.pb.h" #import "TextSecureKitEnv.h" #import +NS_ASSUME_NONNULL_BEGIN + #define TSContactThreadPrefix @"c" @implementation TSContactThread @@ -21,13 +22,12 @@ + (instancetype)getOrCreateThreadWithContactId:(NSString *)contactId transaction:(YapDatabaseReadWriteTransaction *)transaction - envelope:(OWSSignalServiceProtosEnvelope *)envelope + relay:(nullable NSString *)relay { SignalRecipient *recipient = [SignalRecipient recipientWithTextSecureIdentifier:contactId withTransaction:transaction]; if (!recipient) { - NSString *relay = envelope.hasRelay && ![envelope.relay isEqualToString:@""] ? envelope.relay : nil; recipient = [[SignalRecipient alloc] initWithTextSecureIdentifier:contactId relay:relay supportsVoice:YES]; [[ContactsUpdater sharedUpdater] lookupIdentifier:contactId @@ -76,7 +76,8 @@ #if TARGET_OS_IPHONE -- (UIImage *)image { +- (nullable UIImage *)image +{ UIImage *image = [[TextSecureKitEnv sharedEnv].contactsManager imageForPhoneIdentifier:self.contactIdentifier]; return image; } @@ -92,3 +93,5 @@ } @end + +NS_ASSUME_NONNULL_END diff --git a/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeySendingErrorMessage.m b/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeySendingErrorMessage.m index 24a8fd63c..2cba98885 100644 --- a/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeySendingErrorMessage.m +++ b/src/Messages/InvalidKeyMessages/TSInvalidIdentityKeySendingErrorMessage.m @@ -1,22 +1,16 @@ -// -// TSInvalidIdentityKeySendingErrorMessage.m -// Signal -// // Created by Frederic Jacobs on 15/02/15. // Copyright (c) 2015 Open Whisper Systems. All rights reserved. -// - -#import "TSOutgoingMessage.h" - -#import +#import "TSInvalidIdentityKeySendingErrorMessage.h" #import "PreKeyBundle+jsonDict.h" +#import "SignalRecipient.h" #import "TSContactThread.h" #import "TSErrorMessage_privateConstructor.h" #import "TSFingerprintGenerator.h" -#import "TSInvalidIdentityKeySendingErrorMessage.h" #import "TSMessagesManager+sendMessages.h" +#import "TSOutgoingMessage.h" #import "TSStorageManager+IdentityKeyStore.h" +#import @interface TSInvalidIdentityKeySendingErrorMessage () diff --git a/src/Messages/TSMessagesManager.m b/src/Messages/TSMessagesManager.m index 0b4a2394e..63ffbf5aa 100644 --- a/src/Messages/TSMessagesManager.m +++ b/src/Messages/TSMessagesManager.m @@ -341,7 +341,7 @@ } else { TSContactThread *cThread = [TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction - envelope:envelope]; + relay:envelope.relay]; incomingMessage = [[TSIncomingMessage alloc] initWithTimestamp:timeStamp inThread:cThread