TSContactThread doesn't need to know protobufs

Just pass in the relay since that's the only thing we care about

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent f4d90688b9
commit 6ec21ade9b

@ -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

@ -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

@ -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 <Foundation/Foundation.h>
#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

@ -3,10 +3,11 @@
#import "TSContactThread.h"
#import "ContactsUpdater.h"
#import "OWSSignalServiceProtos.pb.h"
#import "TextSecureKitEnv.h"
#import <YapDatabase/YapDatabaseTransaction.h>
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

@ -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 <AxolotlKit/NSData+keyVersionByte.h>
#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 <AxolotlKit/NSData+keyVersionByte.h>
@interface TSInvalidIdentityKeySendingErrorMessage ()

@ -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

Loading…
Cancel
Save