CR: Add back deprecated constructor to debug list

This commit is contained in:
Michael Kirk 2018-07-25 15:19:40 -06:00
parent abcd0a1d29
commit e5856b2ac5
3 changed files with 45 additions and 1 deletions

View File

@ -3553,7 +3553,13 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
withTransaction:transaction]];
[result addObject:[TSErrorMessage corruptedMessageWithEnvelope:[self createEnvelopeForThread:thread]
withTransaction:transaction]];
TSInvalidIdentityKeyReceivingErrorMessage *_Nullable blockingSNChangeMessage =
[TSInvalidIdentityKeyReceivingErrorMessage untrustedKeyWithEnvelope:[self createEnvelopeForThread:thread]
withTransaction:transaction];
OWSAssert(blockingSNChangeMessage);
[result addObject:blockingSNChangeMessage];
[result addObject:[[TSErrorMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread
failedMessageType:TSErrorMessageNonBlockingIdentityChange

View File

@ -6,10 +6,15 @@
NS_ASSUME_NONNULL_BEGIN
@class SSKEnvelope;
// DEPRECATED - we no longer create new instances of this class (as of mid-2017); However, existing instances may
// exist, so we should keep this class around to honor their old behavior.
@interface TSInvalidIdentityKeyReceivingErrorMessage : TSInvalidIdentityKeyErrorMessage
+ (nullable instancetype)untrustedKeyWithEnvelope:(SSKEnvelope *)envelope
withTransaction:(YapDatabaseReadWriteTransaction *)transaction;
@end
NS_ASSUME_NONNULL_END

View File

@ -33,6 +33,39 @@ NS_ASSUME_NONNULL_BEGIN
@synthesize envelopeData = _envelopeData;
+ (nullable instancetype)untrustedKeyWithEnvelope:(SSKEnvelope *)envelope
withTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
TSContactThread *contactThread =
[TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction];
TSInvalidIdentityKeyReceivingErrorMessage *errorMessage =
[[self alloc] initForUnknownIdentityKeyWithTimestamp:envelope.timestamp
inThread:contactThread
incomingEnvelope:envelope];
return errorMessage;
}
- (nullable instancetype)initForUnknownIdentityKeyWithTimestamp:(uint64_t)timestamp
inThread:(TSThread *)thread
incomingEnvelope:(SSKEnvelope *)envelope
{
self = [self initWithTimestamp:timestamp inThread:thread failedMessageType:TSErrorMessageWrongTrustedIdentityKey];
if (!self) {
return self;
}
NSError *error;
_envelopeData = [envelope serializedDataAndReturnError:&error];
if (!_envelopeData || error != nil) {
OWSFail(@"%@ failure: envelope data failed with error: %@", self.logTag, error);
return nil;
}
_authorId = envelope.source;
return self;
}
- (nullable SSKEnvelope *)envelope
{
if (!_envelope) {