|
|
|
@ -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 = @"application/octet-stream";
|
|
|
|
|
}
|
|
|
|
|
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 = @"application/octet-stream";
|
|
|
|
|
}
|
|
|
|
|
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 = @"application/octet-stream";
|
|
|
|
|
}
|
|
|
|
|
_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 = @"application/octet-stream";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|