mirror of https://github.com/oxen-io/session-ios
Support for `remoteRegistrationId`.
1) Supporting `remoteRegistrationId` on sending messages. Now showing warning before sending the message if key conflict exists. Fixes #574 2) Upgrading dependencies: adapting to new libPhoneNumber API. 3) Fixes race condition in database code. 4) Fixing ordering bug. Hopefully once and for good.pull/1/head
parent
cbc7a59a5c
commit
dfdd0a1974
@ -1 +1 @@
|
|||||||
Subproject commit cf26bdeb6884a541de1b72146d01b96a217cc8c9
|
Subproject commit 70c45af296f1ca37139e06f1c1850e3a42ca1383
|
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// TSInvalidIdentityKeyErrorMessage.h
|
||||||
|
// Signal
|
||||||
|
//
|
||||||
|
// Created by Frederic Jacobs on 15/02/15.
|
||||||
|
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "TSErrorMessage.h"
|
||||||
|
|
||||||
|
@interface TSInvalidIdentityKeyErrorMessage : TSErrorMessage
|
||||||
|
|
||||||
|
- (void)acceptNewIdentityKey;
|
||||||
|
- (NSString*)newIdentityKey;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// TSInvalidIdentityKeyErrorMessage.m
|
||||||
|
// Signal
|
||||||
|
//
|
||||||
|
// Created by Frederic Jacobs on 15/02/15.
|
||||||
|
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "TSInvalidIdentityKeyErrorMessage.h"
|
||||||
|
|
||||||
|
@implementation TSInvalidIdentityKeyErrorMessage
|
||||||
|
|
||||||
|
- (void)acceptNewIdentityKey{
|
||||||
|
NSAssert(NO, @"Method needs to be implemented in subclasses of TSInvalidIdentityKeyErrorMessage.");
|
||||||
|
}
|
||||||
|
- (NSString*)newIdentityKey{
|
||||||
|
NSAssert(NO, @"Method needs to be implemented in subclasses of TSInvalidIdentityKeyErrorMessage.");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// TSInvalidIdentityKeySendingErrorMessage.h
|
||||||
|
// Signal
|
||||||
|
//
|
||||||
|
// Created by Frederic Jacobs on 15/02/15.
|
||||||
|
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "TSInvalidIdentityKeyErrorMessage.h"
|
||||||
|
|
||||||
|
@class PreKeyBundle;
|
||||||
|
|
||||||
|
@interface TSInvalidIdentityKeySendingErrorMessage : TSInvalidIdentityKeyErrorMessage
|
||||||
|
|
||||||
|
#define TSInvalidPreKeyBundleKey @"TSInvalidPreKeyBundleKey"
|
||||||
|
#define TSInvalidRecipientKey @"TSInvalidRecipientKey"
|
||||||
|
|
||||||
|
+ (instancetype)untrustedKeyWithOutgoingMessage:(TSOutgoingMessage*)outgoingMessage
|
||||||
|
inThread:(TSThread*)thread
|
||||||
|
forRecipient:(NSString*)recipientId
|
||||||
|
preKeyBundle:(PreKeyBundle*)preKeyBundle
|
||||||
|
withTransaction:(YapDatabaseReadWriteTransaction*)transaction;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,86 @@
|
|||||||
|
//
|
||||||
|
// 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 "NSDate+millisecondTimeStamp.h"
|
||||||
|
#import "PreKeyBundle+jsonDict.h"
|
||||||
|
#import "TSInvalidIdentityKeySendingErrorMessage.h"
|
||||||
|
#import "TSFingerprintGenerator.h"
|
||||||
|
#import "TSErrorMessage_privateConstructor.h"
|
||||||
|
#import "TSStorageManager+IdentityKeyStore.h"
|
||||||
|
#import "TSMessagesManager+sendMessages.h"
|
||||||
|
|
||||||
|
@interface TSInvalidIdentityKeySendingErrorMessage()
|
||||||
|
|
||||||
|
@property (nonatomic, readonly) PreKeyBundle *preKeyBundle;
|
||||||
|
@property (nonatomic, readonly) NSString *recipientId;
|
||||||
|
@property (nonatomic, readonly) NSString *messageId;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation TSInvalidIdentityKeySendingErrorMessage
|
||||||
|
|
||||||
|
- (instancetype)initWithOutgoingMessage:(TSOutgoingMessage*)message
|
||||||
|
inThread:(TSThread*)thread
|
||||||
|
forRecipient:(NSString*)recipientId
|
||||||
|
preKeyBundle:(PreKeyBundle*)preKeyBundle
|
||||||
|
transaction:(YapDatabaseReadWriteTransaction*)transaction
|
||||||
|
{
|
||||||
|
self = [super initWithTimestamp:message.timestamp inThread:thread failedMessageType:TSErrorMessageWrongTrustedIdentityKey];
|
||||||
|
|
||||||
|
if (self) {
|
||||||
|
_messageId = message.uniqueId;
|
||||||
|
_preKeyBundle = preKeyBundle;
|
||||||
|
_recipientId = recipientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)untrustedKeyWithOutgoingMessage:(TSOutgoingMessage*)outgoingMessage
|
||||||
|
inThread:(TSThread*)thread
|
||||||
|
forRecipient:(NSString*)recipientId
|
||||||
|
preKeyBundle:(PreKeyBundle*)preKeyBundle
|
||||||
|
withTransaction:(YapDatabaseReadWriteTransaction*)transaction
|
||||||
|
{
|
||||||
|
TSInvalidIdentityKeySendingErrorMessage *message = [[self alloc] initWithOutgoingMessage:outgoingMessage inThread:thread forRecipient:recipientId preKeyBundle:preKeyBundle transaction:transaction];
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)acceptNewIdentityKey {
|
||||||
|
[[TSStorageManager sharedManager] saveRemoteIdentity:[self newKey] recipientId:_recipientId];
|
||||||
|
|
||||||
|
__block TSOutgoingMessage *message;
|
||||||
|
__block TSThread *thread;
|
||||||
|
|
||||||
|
[[TSStorageManager sharedManager].newDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||||
|
thread = [TSContactThread fetchObjectWithUniqueID:self.uniqueThreadId transaction:transaction];
|
||||||
|
message = [TSOutgoingMessage fetchObjectWithUniqueID:_messageId transaction:transaction];
|
||||||
|
|
||||||
|
[self removeWithTransaction:transaction];
|
||||||
|
}];
|
||||||
|
|
||||||
|
if (message) {
|
||||||
|
[[TSMessagesManager sharedManager] sendMessage:message inThread:thread];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*)newIdentityKey {
|
||||||
|
NSData *identityKey = [self newKey];
|
||||||
|
|
||||||
|
return [TSFingerprintGenerator getFingerprintForDisplay:identityKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSData*)newKey {
|
||||||
|
return [self.preKeyBundle.identityKey removeKeyType];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in New Issue