Don't send profile key with every sync message since we explicitly sync

upon update/create.

Following Signal-Android's lead here.

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 526d5e33b9
commit 6235e7fe5c

@ -154,11 +154,6 @@ message SyncMessage {
optional Blocked blocked = 6; optional Blocked blocked = 6;
optional Verified verified = 7; optional Verified verified = 7;
optional bytes padding = 8; optional bytes padding = 8;
// Signal-iOS includes profileKey in *every* Sync message
// We should change this so as not to bloat our sync message size
// since sync messages are sent all the time and we only need to
// send a key once.
optional bytes profileKey = 9;
} }
message AttachmentPointer { message AttachmentPointer {

@ -32,8 +32,6 @@ NS_ASSUME_NONNULL_BEGIN
size_t paddingBytesLength = arc4random_uniform(512) + 1; size_t paddingBytesLength = arc4random_uniform(512) + 1;
builder.padding = [Cryptography generateRandomBytes:paddingBytesLength]; builder.padding = [Cryptography generateRandomBytes:paddingBytesLength];
[builder addLocalProfileKey];
return [builder build]; return [builder build];
} }

@ -1007,7 +1007,6 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
#define SyncMessage_blocked @"blocked" #define SyncMessage_blocked @"blocked"
#define SyncMessage_verified @"verified" #define SyncMessage_verified @"verified"
#define SyncMessage_padding @"padding" #define SyncMessage_padding @"padding"
#define SyncMessage_profileKey @"profileKey"
@interface OWSSignalServiceProtosSyncMessage : PBGeneratedMessage<GeneratedMessageProtocol> { @interface OWSSignalServiceProtosSyncMessage : PBGeneratedMessage<GeneratedMessageProtocol> {
@private @private
BOOL hasSent_:1; BOOL hasSent_:1;
@ -1017,7 +1016,6 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
BOOL hasBlocked_:1; BOOL hasBlocked_:1;
BOOL hasVerified_:1; BOOL hasVerified_:1;
BOOL hasPadding_:1; BOOL hasPadding_:1;
BOOL hasProfileKey_:1;
OWSSignalServiceProtosSyncMessageSent* sent; OWSSignalServiceProtosSyncMessageSent* sent;
OWSSignalServiceProtosSyncMessageContacts* contacts; OWSSignalServiceProtosSyncMessageContacts* contacts;
OWSSignalServiceProtosSyncMessageGroups* groups; OWSSignalServiceProtosSyncMessageGroups* groups;
@ -1025,7 +1023,6 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
OWSSignalServiceProtosSyncMessageBlocked* blocked; OWSSignalServiceProtosSyncMessageBlocked* blocked;
OWSSignalServiceProtosVerified* verified; OWSSignalServiceProtosVerified* verified;
NSData* padding; NSData* padding;
NSData* profileKey;
NSMutableArray * readArray; NSMutableArray * readArray;
} }
- (BOOL) hasSent; - (BOOL) hasSent;
@ -1035,7 +1032,6 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
- (BOOL) hasBlocked; - (BOOL) hasBlocked;
- (BOOL) hasVerified; - (BOOL) hasVerified;
- (BOOL) hasPadding; - (BOOL) hasPadding;
- (BOOL) hasProfileKey;
@property (readonly, strong) OWSSignalServiceProtosSyncMessageSent* sent; @property (readonly, strong) OWSSignalServiceProtosSyncMessageSent* sent;
@property (readonly, strong) OWSSignalServiceProtosSyncMessageContacts* contacts; @property (readonly, strong) OWSSignalServiceProtosSyncMessageContacts* contacts;
@property (readonly, strong) OWSSignalServiceProtosSyncMessageGroups* groups; @property (readonly, strong) OWSSignalServiceProtosSyncMessageGroups* groups;
@ -1044,7 +1040,6 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
@property (readonly, strong) OWSSignalServiceProtosSyncMessageBlocked* blocked; @property (readonly, strong) OWSSignalServiceProtosSyncMessageBlocked* blocked;
@property (readonly, strong) OWSSignalServiceProtosVerified* verified; @property (readonly, strong) OWSSignalServiceProtosVerified* verified;
@property (readonly, strong) NSData* padding; @property (readonly, strong) NSData* padding;
@property (readonly, strong) NSData* profileKey;
- (OWSSignalServiceProtosSyncMessageRead*)readAtIndex:(NSUInteger)index; - (OWSSignalServiceProtosSyncMessageRead*)readAtIndex:(NSUInteger)index;
+ (instancetype) defaultInstance; + (instancetype) defaultInstance;
@ -1490,11 +1485,6 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
- (NSData*) padding; - (NSData*) padding;
- (OWSSignalServiceProtosSyncMessageBuilder*) setPadding:(NSData*) value; - (OWSSignalServiceProtosSyncMessageBuilder*) setPadding:(NSData*) value;
- (OWSSignalServiceProtosSyncMessageBuilder*) clearPadding; - (OWSSignalServiceProtosSyncMessageBuilder*) clearPadding;
- (BOOL) hasProfileKey;
- (NSData*) profileKey;
- (OWSSignalServiceProtosSyncMessageBuilder*) setProfileKey:(NSData*) value;
- (OWSSignalServiceProtosSyncMessageBuilder*) clearProfileKey;
@end @end
#define AttachmentPointer_id @"id" #define AttachmentPointer_id @"id"

@ -3947,7 +3947,6 @@ NSString *NSStringFromOWSSignalServiceProtosVerifiedState(OWSSignalServiceProtos
@property (strong) OWSSignalServiceProtosSyncMessageBlocked* blocked; @property (strong) OWSSignalServiceProtosSyncMessageBlocked* blocked;
@property (strong) OWSSignalServiceProtosVerified* verified; @property (strong) OWSSignalServiceProtosVerified* verified;
@property (strong) NSData* padding; @property (strong) NSData* padding;
@property (strong) NSData* profileKey;
@end @end
@implementation OWSSignalServiceProtosSyncMessage @implementation OWSSignalServiceProtosSyncMessage
@ -4003,13 +4002,6 @@ NSString *NSStringFromOWSSignalServiceProtosVerifiedState(OWSSignalServiceProtos
hasPadding_ = !!_value_; hasPadding_ = !!_value_;
} }
@synthesize padding; @synthesize padding;
- (BOOL) hasProfileKey {
return !!hasProfileKey_;
}
- (void) setHasProfileKey:(BOOL) _value_ {
hasProfileKey_ = !!_value_;
}
@synthesize profileKey;
- (instancetype) init { - (instancetype) init {
if ((self = [super init])) { if ((self = [super init])) {
self.sent = [OWSSignalServiceProtosSyncMessageSent defaultInstance]; self.sent = [OWSSignalServiceProtosSyncMessageSent defaultInstance];
@ -4019,7 +4011,6 @@ NSString *NSStringFromOWSSignalServiceProtosVerifiedState(OWSSignalServiceProtos
self.blocked = [OWSSignalServiceProtosSyncMessageBlocked defaultInstance]; self.blocked = [OWSSignalServiceProtosSyncMessageBlocked defaultInstance];
self.verified = [OWSSignalServiceProtosVerified defaultInstance]; self.verified = [OWSSignalServiceProtosVerified defaultInstance];
self.padding = [NSData data]; self.padding = [NSData data];
self.profileKey = [NSData data];
} }
return self; return self;
} }
@ -4069,9 +4060,6 @@ static OWSSignalServiceProtosSyncMessage* defaultOWSSignalServiceProtosSyncMessa
if (self.hasPadding) { if (self.hasPadding) {
[output writeData:8 value:self.padding]; [output writeData:8 value:self.padding];
} }
if (self.hasProfileKey) {
[output writeData:9 value:self.profileKey];
}
[self.unknownFields writeToCodedOutputStream:output]; [self.unknownFields writeToCodedOutputStream:output];
} }
- (SInt32) serializedSize { - (SInt32) serializedSize {
@ -4105,9 +4093,6 @@ static OWSSignalServiceProtosSyncMessage* defaultOWSSignalServiceProtosSyncMessa
if (self.hasPadding) { if (self.hasPadding) {
size_ += computeDataSize(8, self.padding); size_ += computeDataSize(8, self.padding);
} }
if (self.hasProfileKey) {
size_ += computeDataSize(9, self.profileKey);
}
size_ += self.unknownFields.serializedSize; size_ += self.unknownFields.serializedSize;
memoizedSerializedSize = size_; memoizedSerializedSize = size_;
return size_; return size_;
@ -4188,9 +4173,6 @@ static OWSSignalServiceProtosSyncMessage* defaultOWSSignalServiceProtosSyncMessa
if (self.hasPadding) { if (self.hasPadding) {
[output appendFormat:@"%@%@: %@\n", indent, @"padding", self.padding]; [output appendFormat:@"%@%@: %@\n", indent, @"padding", self.padding];
} }
if (self.hasProfileKey) {
[output appendFormat:@"%@%@: %@\n", indent, @"profileKey", self.profileKey];
}
[self.unknownFields writeDescriptionTo:output withIndent:indent]; [self.unknownFields writeDescriptionTo:output withIndent:indent];
} }
- (void) storeInDictionary:(NSMutableDictionary *)dictionary { - (void) storeInDictionary:(NSMutableDictionary *)dictionary {
@ -4232,9 +4214,6 @@ static OWSSignalServiceProtosSyncMessage* defaultOWSSignalServiceProtosSyncMessa
if (self.hasPadding) { if (self.hasPadding) {
[dictionary setObject: self.padding forKey: @"padding"]; [dictionary setObject: self.padding forKey: @"padding"];
} }
if (self.hasProfileKey) {
[dictionary setObject: self.profileKey forKey: @"profileKey"];
}
[self.unknownFields storeInDictionary:dictionary]; [self.unknownFields storeInDictionary:dictionary];
} }
- (BOOL) isEqual:(id)other { - (BOOL) isEqual:(id)other {
@ -4261,8 +4240,6 @@ static OWSSignalServiceProtosSyncMessage* defaultOWSSignalServiceProtosSyncMessa
(!self.hasVerified || [self.verified isEqual:otherMessage.verified]) && (!self.hasVerified || [self.verified isEqual:otherMessage.verified]) &&
self.hasPadding == otherMessage.hasPadding && self.hasPadding == otherMessage.hasPadding &&
(!self.hasPadding || [self.padding isEqual:otherMessage.padding]) && (!self.hasPadding || [self.padding isEqual:otherMessage.padding]) &&
self.hasProfileKey == otherMessage.hasProfileKey &&
(!self.hasProfileKey || [self.profileKey isEqual:otherMessage.profileKey]) &&
(self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields])); (self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields]));
} }
- (NSUInteger) hash { - (NSUInteger) hash {
@ -4291,9 +4268,6 @@ static OWSSignalServiceProtosSyncMessage* defaultOWSSignalServiceProtosSyncMessa
if (self.hasPadding) { if (self.hasPadding) {
hashCode = hashCode * 31 + [self.padding hash]; hashCode = hashCode * 31 + [self.padding hash];
} }
if (self.hasProfileKey) {
hashCode = hashCode * 31 + [self.profileKey hash];
}
hashCode = hashCode * 31 + [self.unknownFields hash]; hashCode = hashCode * 31 + [self.unknownFields hash];
return hashCode; return hashCode;
} }
@ -5966,9 +5940,6 @@ static OWSSignalServiceProtosSyncMessageRead* defaultOWSSignalServiceProtosSyncM
if (other.hasPadding) { if (other.hasPadding) {
[self setPadding:other.padding]; [self setPadding:other.padding];
} }
if (other.hasProfileKey) {
[self setProfileKey:other.profileKey];
}
[self mergeUnknownFields:other.unknownFields]; [self mergeUnknownFields:other.unknownFields];
return self; return self;
} }
@ -6054,10 +6025,6 @@ static OWSSignalServiceProtosSyncMessageRead* defaultOWSSignalServiceProtosSyncM
[self setPadding:[input readData]]; [self setPadding:[input readData]];
break; break;
} }
case 74: {
[self setProfileKey:[input readData]];
break;
}
} }
} }
} }
@ -6278,22 +6245,6 @@ static OWSSignalServiceProtosSyncMessageRead* defaultOWSSignalServiceProtosSyncM
resultSyncMessage.padding = [NSData data]; resultSyncMessage.padding = [NSData data];
return self; return self;
} }
- (BOOL) hasProfileKey {
return resultSyncMessage.hasProfileKey;
}
- (NSData*) profileKey {
return resultSyncMessage.profileKey;
}
- (OWSSignalServiceProtosSyncMessageBuilder*) setProfileKey:(NSData*) value {
resultSyncMessage.hasProfileKey = YES;
resultSyncMessage.profileKey = value;
return self;
}
- (OWSSignalServiceProtosSyncMessageBuilder*) clearProfileKey {
resultSyncMessage.hasProfileKey = NO;
resultSyncMessage.profileKey = [NSData data];
return self;
}
@end @end
@interface OWSSignalServiceProtosAttachmentPointer () @interface OWSSignalServiceProtosAttachmentPointer ()

@ -28,12 +28,4 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
#pragma mark -
@interface OWSSignalServiceProtosSyncMessageBuilder (OWS)
- (void)addLocalProfileKey;
@end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -90,15 +90,4 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
#pragma mark -
@implementation OWSSignalServiceProtosSyncMessageBuilder (OWS)
- (void)addLocalProfileKey
{
[self setProfileKey:self.localProfileKey.keyData];
}
@end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

Loading…
Cancel
Save