|
|
|
@ -22,7 +22,7 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
|
|
|
|
|
- (instancetype)initWithServerId:(UInt64)serverId
|
|
|
|
|
encryptionKey:(NSData *)encryptionKey
|
|
|
|
|
contentType:(NSString *)contentType
|
|
|
|
|
filename:(nullable NSString *)filename
|
|
|
|
|
sourceFilename:(nullable NSString *)sourceFilename
|
|
|
|
|
{
|
|
|
|
|
self = [super init];
|
|
|
|
|
if (!self) {
|
|
|
|
@ -33,14 +33,14 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
|
|
|
|
|
_encryptionKey = encryptionKey;
|
|
|
|
|
_contentType = contentType;
|
|
|
|
|
_attachmentSchemaVersion = TSAttachmentSchemaVersion;
|
|
|
|
|
_filename = filename;
|
|
|
|
|
_sourceFilename = sourceFilename;
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This constructor is used for new instances of TSAttachmentStream
|
|
|
|
|
// that represent new, un-uploaded outgoing attachments.
|
|
|
|
|
- (instancetype)initWithContentType:(NSString *)contentType filename:(nullable NSString *)filename
|
|
|
|
|
- (instancetype)initWithContentType:(NSString *)contentType sourceFilename:(nullable NSString *)sourceFilename
|
|
|
|
|
{
|
|
|
|
|
self = [super init];
|
|
|
|
|
if (!self) {
|
|
|
|
@ -49,7 +49,7 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
|
|
|
|
|
|
|
|
|
|
_contentType = contentType;
|
|
|
|
|
_attachmentSchemaVersion = TSAttachmentSchemaVersion;
|
|
|
|
|
_filename = filename;
|
|
|
|
|
_sourceFilename = sourceFilename;
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -67,7 +67,7 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
|
|
|
|
|
_serverId = pointer.serverId;
|
|
|
|
|
_encryptionKey = pointer.encryptionKey;
|
|
|
|
|
_contentType = pointer.contentType;
|
|
|
|
|
_filename = pointer.filename;
|
|
|
|
|
_sourceFilename = pointer.sourceFilename;
|
|
|
|
|
_attachmentSchemaVersion = TSAttachmentSchemaVersion;
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
@ -85,6 +85,12 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
|
|
|
|
|
_attachmentSchemaVersion = TSAttachmentSchemaVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_sourceFilename) {
|
|
|
|
|
// renamed _filename to _sourceFilename
|
|
|
|
|
_sourceFilename = [coder decodeObjectForKey:@"filename"];
|
|
|
|
|
OWSAssert(_sourceFilename || [_sourceFilename isKindOfClass:[NSString class]]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -107,9 +113,9 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
|
|
|
|
|
return [NSString stringWithFormat:@"📽 %@", attachmentString];
|
|
|
|
|
} else if ([MIMETypeUtil isAudio:self.contentType]) {
|
|
|
|
|
|
|
|
|
|
// a missing filename is the legacy way to determin if an audio attachment is a voice note vs. other arbitrary
|
|
|
|
|
// audio attachments.
|
|
|
|
|
if (self.isVoiceMessage || !self.filename || self.filename.length == 0) {
|
|
|
|
|
// a missing filename is the legacy way to determine if an audio attachment is
|
|
|
|
|
// a voice note vs. other arbitrary audio attachments.
|
|
|
|
|
if (self.isVoiceMessage || !self.sourceFilename || self.sourceFilename.length == 0) {
|
|
|
|
|
attachmentString = NSLocalizedString(@"ATTACHMENT_TYPE_VOICE_MESSAGE",
|
|
|
|
|
@"Short text label for a voice message attachment, used for thread preview and on lockscreen");
|
|
|
|
|
return [NSString stringWithFormat:@"🎤 %@", attachmentString];
|
|
|
|
|