remove legacy message sending

// FREEBIE
pull/1/head
Michael Kirk 8 years ago committed by Matthew Chen
parent 13a119b4b6
commit c29549c213

@ -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 "OWSOutgoingSyncMessage.h"
#import "OWSSignalServiceProtos.pb.h" #import "OWSSignalServiceProtos.pb.h"
@ -19,11 +21,6 @@ NS_ASSUME_NONNULL_BEGIN
return NO; return NO;
} }
- (BOOL)isLegacyMessage
{
return NO;
}
- (OWSSignalServiceProtosSyncMessage *)buildSyncMessage - (OWSSignalServiceProtosSyncMessage *)buildSyncMessage
{ {
NSAssert(NO, @"buildSyncMessage must be overridden in subclass"); NSAssert(NO, @"buildSyncMessage must be overridden in subclass");

@ -97,13 +97,6 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
// If set, this group message should only be sent to a single recipient. // If set, this group message should only be sent to a single recipient.
@property (atomic, readonly) NSString *singleGroupRecipient; @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; @property (nonatomic, readonly) BOOL isVoiceMessage;
/** /**

@ -451,12 +451,10 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
// For modern messages, e.g. Sync and Call messages, this is a serialized Contact // For modern messages, e.g. Sync and Call messages, this is a serialized Contact
- (NSData *)buildPlainTextData - (NSData *)buildPlainTextData
{ {
return [[self buildDataMessage] data]; OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
} contentBuilder.dataMessage = [self buildDataMessage];
- (BOOL)isLegacyMessage return [[contentBuilder build] data];
{
return YES;
} }
- (BOOL)shouldSyncTranscript - (BOOL)shouldSyncTranscript

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

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

@ -11,7 +11,6 @@
#import "OWSDisappearingMessagesJob.h" #import "OWSDisappearingMessagesJob.h"
#import "OWSError.h" #import "OWSError.h"
#import "OWSIdentityManager.h" #import "OWSIdentityManager.h"
#import "OWSLegacyMessageServiceParams.h"
#import "OWSMessageServiceParams.h" #import "OWSMessageServiceParams.h"
#import "OWSOutgoingSentMessageTranscript.h" #import "OWSOutgoingSentMessageTranscript.h"
#import "OWSOutgoingSyncMessage.h" #import "OWSOutgoingSyncMessage.h"
@ -1155,8 +1154,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
messageDict = [self encryptedMessageWithPlaintext:plainText messageDict = [self encryptedMessageWithPlaintext:plainText
toRecipient:recipient.uniqueId toRecipient:recipient.uniqueId
deviceId:deviceNumber deviceId:deviceNumber
keyingStorage:[TSStorageManager sharedManager] keyingStorage:[TSStorageManager sharedManager]];
legacy:message.isLegacyMessage];
} @catch (NSException *exception) { } @catch (NSException *exception) {
encryptionException = exception; encryptionException = exception;
} }
@ -1189,7 +1187,6 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
toRecipient:(NSString *)identifier toRecipient:(NSString *)identifier
deviceId:(NSNumber *)deviceNumber deviceId:(NSNumber *)deviceNumber
keyingStorage:(TSStorageManager *)storage keyingStorage:(TSStorageManager *)storage
legacy:(BOOL)isLegacymessage
{ {
if (![storage containsSession:identifier deviceId:[deviceNumber intValue]]) { if (![storage containsSession:identifier deviceId:[deviceNumber intValue]]) {
__block dispatch_semaphore_t sema = dispatch_semaphore_create(0); __block dispatch_semaphore_t sema = dispatch_semaphore_create(0);
@ -1263,21 +1260,11 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
NSData *serializedMessage = encryptedMessage.serialized; NSData *serializedMessage = encryptedMessage.serialized;
TSWhisperMessageType messageType = [self messageTypeForCipherMessage:encryptedMessage]; TSWhisperMessageType messageType = [self messageTypeForCipherMessage:encryptedMessage];
OWSMessageServiceParams *messageParams; OWSMessageServiceParams *messageParams = [[OWSMessageServiceParams alloc] initWithType:messageType
// DEPRECATED - Remove after all clients have been upgraded. recipientId:identifier
if (isLegacymessage) { device:[deviceNumber intValue]
messageParams = [[OWSLegacyMessageServiceParams alloc] initWithType:messageType content:serializedMessage
recipientId:identifier registrationId:cipher.remoteRegistrationId];
device:[deviceNumber intValue]
body:serializedMessage
registrationId:cipher.remoteRegistrationId];
} else {
messageParams = [[OWSMessageServiceParams alloc] initWithType:messageType
recipientId:identifier
device:[deviceNumber intValue]
content:serializedMessage
registrationId:cipher.remoteRegistrationId];
}
NSError *error; NSError *error;
NSDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:messageParams error:&error]; NSDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:messageParams error:&error];

@ -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 "OWSOutgoingCallMessage.h"
#import "NSDate+millisecondTimeStamp.h" #import "NSDate+millisecondTimeStamp.h"
@ -109,10 +110,6 @@ NS_ASSUME_NONNULL_BEGIN
return NO; return NO;
} }
- (BOOL)isLegacyMessage
{
return NO;
}
// //
///** ///**
// * override thread accessor in superclass, since this model is never saved. // * override thread accessor in superclass, since this model is never saved.

Loading…
Cancel
Save