From c29549c2138ea2b3fa01594f70e7a3414a9ee75b Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 8 Jun 2017 22:23:18 -0400 Subject: [PATCH] remove legacy message sending // FREEBIE --- .../DeviceSyncing/OWSOutgoingSyncMessage.m | 9 ++--- src/Messages/Interactions/TSOutgoingMessage.h | 7 ---- src/Messages/Interactions/TSOutgoingMessage.m | 8 ++--- src/Messages/OWSLegacyMessageServiceParams.h | 20 ----------- src/Messages/OWSLegacyMessageServiceParams.m | 33 ------------------- src/Messages/OWSMessageSender.m | 25 ++++---------- src/Messages/OWSOutgoingCallMessage.m | 9 ++--- 7 files changed, 15 insertions(+), 96 deletions(-) delete mode 100644 src/Messages/OWSLegacyMessageServiceParams.h delete mode 100644 src/Messages/OWSLegacyMessageServiceParams.m diff --git a/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m b/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m index 03800692f..1138d0592 100644 --- a/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m +++ b/src/Messages/DeviceSyncing/OWSOutgoingSyncMessage.m @@ -1,4 +1,6 @@ -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "OWSOutgoingSyncMessage.h" #import "OWSSignalServiceProtos.pb.h" @@ -19,11 +21,6 @@ NS_ASSUME_NONNULL_BEGIN return NO; } -- (BOOL)isLegacyMessage -{ - return NO; -} - - (OWSSignalServiceProtosSyncMessage *)buildSyncMessage { NSAssert(NO, @"buildSyncMessage must be overridden in subclass"); diff --git a/src/Messages/Interactions/TSOutgoingMessage.h b/src/Messages/Interactions/TSOutgoingMessage.h index fabe81ccc..60215e710 100644 --- a/src/Messages/Interactions/TSOutgoingMessage.h +++ b/src/Messages/Interactions/TSOutgoingMessage.h @@ -97,13 +97,6 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) { // If set, this group message should only be sent to a single recipient. @property (atomic, readonly) NSString *singleGroupRecipient; -/** - * Whether the message should be serialized as a modern aka Content, or the old style legacy message. - * Sync and Call messsages must be sent as Content, but other old style DataMessage payloads should be - * sent as legacy message until we're confident no significant number of legacy clients exist in the wild. - */ -@property (nonatomic, readonly) BOOL isLegacyMessage; - @property (nonatomic, readonly) BOOL isVoiceMessage; /** diff --git a/src/Messages/Interactions/TSOutgoingMessage.m b/src/Messages/Interactions/TSOutgoingMessage.m index f5e0c3059..07b1b765a 100644 --- a/src/Messages/Interactions/TSOutgoingMessage.m +++ b/src/Messages/Interactions/TSOutgoingMessage.m @@ -451,12 +451,10 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec // For modern messages, e.g. Sync and Call messages, this is a serialized Contact - (NSData *)buildPlainTextData { - return [[self buildDataMessage] data]; -} + OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new]; + contentBuilder.dataMessage = [self buildDataMessage]; -- (BOOL)isLegacyMessage -{ - return YES; + return [[contentBuilder build] data]; } - (BOOL)shouldSyncTranscript diff --git a/src/Messages/OWSLegacyMessageServiceParams.h b/src/Messages/OWSLegacyMessageServiceParams.h deleted file mode 100644 index f15fface4..000000000 --- a/src/Messages/OWSLegacyMessageServiceParams.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright © 2016 Open Whisper Systems. All rights reserved. - -#import "OWSMessageServiceParams.h" - -NS_ASSUME_NONNULL_BEGIN -/** - * Contstructs the per-device-message parameters used when submitting a message to - * the Signal Web Service. Using a legacy parameter format. Cannot be used for Sync messages. - */ -@interface OWSLegacyMessageServiceParams : OWSMessageServiceParams - -- (instancetype)initWithType:(TSWhisperMessageType)type - recipientId:(NSString *)destination - device:(int)deviceId - body:(NSData *)body - registrationId:(int)registrationId; - -@end - -NS_ASSUME_NONNULL_END diff --git a/src/Messages/OWSLegacyMessageServiceParams.m b/src/Messages/OWSLegacyMessageServiceParams.m deleted file mode 100644 index 79901c508..000000000 --- a/src/Messages/OWSLegacyMessageServiceParams.m +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright © 2016 Open Whisper Systems. All rights reserved. - -#import "OWSLegacyMessageServiceParams.h" - -NS_ASSUME_NONNULL_BEGIN - -@implementation OWSLegacyMessageServiceParams - -+ (NSDictionary *)JSONKeyPathsByPropertyKey -{ - NSMutableDictionary *keys = [[super JSONKeyPathsByPropertyKey] mutableCopy]; - [keys setObject:@"body" forKey:@"content"]; - return [keys copy]; -} - -- (instancetype)initWithType:(TSWhisperMessageType)type - recipientId:(NSString *)destination - device:(int)deviceId - body:(NSData *)body - registrationId:(int)registrationId -{ - self = [super initWithType:type recipientId:destination device:deviceId content:body registrationId:registrationId]; - if (!self) { - return self; - } - - return self; -} - - -@end - -NS_ASSUME_NONNULL_END diff --git a/src/Messages/OWSMessageSender.m b/src/Messages/OWSMessageSender.m index c68e1ab96..6c812b460 100644 --- a/src/Messages/OWSMessageSender.m +++ b/src/Messages/OWSMessageSender.m @@ -11,7 +11,6 @@ #import "OWSDisappearingMessagesJob.h" #import "OWSError.h" #import "OWSIdentityManager.h" -#import "OWSLegacyMessageServiceParams.h" #import "OWSMessageServiceParams.h" #import "OWSOutgoingSentMessageTranscript.h" #import "OWSOutgoingSyncMessage.h" @@ -1155,8 +1154,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; messageDict = [self encryptedMessageWithPlaintext:plainText toRecipient:recipient.uniqueId deviceId:deviceNumber - keyingStorage:[TSStorageManager sharedManager] - legacy:message.isLegacyMessage]; + keyingStorage:[TSStorageManager sharedManager]]; } @catch (NSException *exception) { encryptionException = exception; } @@ -1189,7 +1187,6 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; toRecipient:(NSString *)identifier deviceId:(NSNumber *)deviceNumber keyingStorage:(TSStorageManager *)storage - legacy:(BOOL)isLegacymessage { if (![storage containsSession:identifier deviceId:[deviceNumber intValue]]) { __block dispatch_semaphore_t sema = dispatch_semaphore_create(0); @@ -1263,21 +1260,11 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; NSData *serializedMessage = encryptedMessage.serialized; TSWhisperMessageType messageType = [self messageTypeForCipherMessage:encryptedMessage]; - OWSMessageServiceParams *messageParams; - // DEPRECATED - Remove after all clients have been upgraded. - if (isLegacymessage) { - messageParams = [[OWSLegacyMessageServiceParams alloc] initWithType:messageType - recipientId:identifier - device:[deviceNumber intValue] - body:serializedMessage - registrationId:cipher.remoteRegistrationId]; - } else { - messageParams = [[OWSMessageServiceParams alloc] initWithType:messageType - recipientId:identifier - device:[deviceNumber intValue] - content:serializedMessage - registrationId:cipher.remoteRegistrationId]; - } + OWSMessageServiceParams *messageParams = [[OWSMessageServiceParams alloc] initWithType:messageType + recipientId:identifier + device:[deviceNumber intValue] + content:serializedMessage + registrationId:cipher.remoteRegistrationId]; NSError *error; NSDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:messageParams error:&error]; diff --git a/src/Messages/OWSOutgoingCallMessage.m b/src/Messages/OWSOutgoingCallMessage.m index 13e816a4f..b1907b8a1 100644 --- a/src/Messages/OWSOutgoingCallMessage.m +++ b/src/Messages/OWSOutgoingCallMessage.m @@ -1,5 +1,6 @@ -// Created by Michael Kirk on 12/1/16. -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "OWSOutgoingCallMessage.h" #import "NSDate+millisecondTimeStamp.h" @@ -109,10 +110,6 @@ NS_ASSUME_NONNULL_BEGIN return NO; } -- (BOOL)isLegacyMessage -{ - return NO; -} // ///** // * override thread accessor in superclass, since this model is never saved.