Set the protocol version when sending a new style attachment

This commit is contained in:
Ehren Kret 2020-04-10 19:01:35 -07:00
parent 510a32b98a
commit d24bceeeff
2 changed files with 7 additions and 2 deletions

View File

@ -1155,6 +1155,8 @@ typedef void (^OWSLoadedThumbnailSuccess)(OWSLoadedThumbnail *loadedThumbnail);
SSKProtoAttachmentPointerBuilder *builder = [SSKProtoAttachmentPointer builder];
builder.cdnID = self.serverId;
builder.cdnKey = self.cdnKey;
builder.cdnNumber = self.cdnNumber;
OWSAssertDebug(self.contentType.length > 0);
builder.contentType = self.contentType;

View File

@ -1048,8 +1048,6 @@ NSUInteger const TSOutgoingMessageSchemaVersion = 1;
requiredProtocolVersion = SSKProtoDataMessageProtocolVersionViewOnceVideo;
}
[builder setRequiredProtocolVersion:(uint32_t)requiredProtocolVersion];
if ([self.body lengthOfBytesUsingEncoding:NSUTF8StringEncoding] <= kOversizeTextMessageSizeThreshold) {
[builder setBody:self.body];
} else {
@ -1099,6 +1097,10 @@ NSUInteger const TSOutgoingMessageSchemaVersion = 1;
return nil;
}
[attachments addObject:attachmentProto];
if (requiredProtocolVersion < SSKProtoDataMessageProtocolVersionCdnSelectorAttachments
&& (attachmentProto.cdnKey.length > 0 || attachmentProto.cdnNumber > 0)) {
requiredProtocolVersion = SSKProtoDataMessageProtocolVersionCdnSelectorAttachments;
}
}
[builder setAttachments:attachments];
}
@ -1177,6 +1179,7 @@ NSUInteger const TSOutgoingMessageSchemaVersion = 1;
}
}
[builder setRequiredProtocolVersion:(uint32_t)requiredProtocolVersion];
return builder;
}