mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/ensureAttachmentContentType'
This commit is contained in:
commit
0cd49e597e
2 changed files with 24 additions and 1 deletions
|
@ -31,6 +31,11 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
|
|||
// This will fail with legacy iOS clients which don't upload attachment size.
|
||||
DDLogWarn(@"%@ Missing byteCount for attachment with serverId: %lld", self.tag, serverId);
|
||||
}
|
||||
if (contentType.length < 1) {
|
||||
DDLogWarn(@"%@ incoming attachment has invalid content type", self.tag);
|
||||
|
||||
contentType = OWSMimeTypeApplicationOctetStream;
|
||||
}
|
||||
OWSAssert(contentType.length > 0);
|
||||
|
||||
self = [super init];
|
||||
|
@ -55,6 +60,11 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
|
|||
byteCount:(UInt32)byteCount
|
||||
sourceFilename:(nullable NSString *)sourceFilename
|
||||
{
|
||||
if (contentType.length < 1) {
|
||||
DDLogWarn(@"%@ outgoing attachment has invalid content type", self.tag);
|
||||
|
||||
contentType = OWSMimeTypeApplicationOctetStream;
|
||||
}
|
||||
OWSAssert(contentType.length > 0);
|
||||
OWSAssert(byteCount > 0);
|
||||
|
||||
|
@ -93,8 +103,14 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
|
|||
_serverId = pointer.serverId;
|
||||
_encryptionKey = pointer.encryptionKey;
|
||||
_byteCount = pointer.byteCount;
|
||||
_contentType = pointer.contentType;
|
||||
_sourceFilename = pointer.sourceFilename;
|
||||
NSString *contentType = pointer.contentType;
|
||||
if (contentType.length < 1) {
|
||||
DDLogWarn(@"%@ incoming attachment has invalid content type", self.tag);
|
||||
|
||||
contentType = OWSMimeTypeApplicationOctetStream;
|
||||
}
|
||||
_contentType = contentType;
|
||||
|
||||
_attachmentSchemaVersion = TSAttachmentSchemaVersion;
|
||||
|
||||
|
@ -119,6 +135,12 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
|
|||
OWSAssert(!_sourceFilename || [_sourceFilename isKindOfClass:[NSString class]]);
|
||||
}
|
||||
|
||||
if (_contentType.length < 1) {
|
||||
DDLogWarn(@"%@ legacy attachment has invalid content type", self.tag);
|
||||
|
||||
_contentType = OWSMimeTypeApplicationOctetStream;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -541,6 +541,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
|
|||
|
||||
OWSSignalServiceProtosAttachmentPointerBuilder *builder = [OWSSignalServiceProtosAttachmentPointerBuilder new];
|
||||
[builder setId:attachmentStream.serverId];
|
||||
OWSAssert(attachmentStream.contentType.length > 0);
|
||||
[builder setContentType:attachmentStream.contentType];
|
||||
[builder setFileName:filename];
|
||||
[builder setSize:attachmentStream.byteCount];
|
||||
|
|
Loading…
Reference in a new issue