From 75fabe5c255f13c8befbc1c8f35ce8a7c5a23087 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 27 Mar 2017 18:05:04 -0400 Subject: [PATCH] Add support for oversize text messages sent as attachments. // FREEBIE --- src/Util/MIMETypeUtil.h | 1 + src/Util/MIMETypeUtil.m | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/Util/MIMETypeUtil.h b/src/Util/MIMETypeUtil.h index 5f34a2969..17bbfe55f 100644 --- a/src/Util/MIMETypeUtil.h +++ b/src/Util/MIMETypeUtil.h @@ -4,6 +4,7 @@ extern NSString *const OWSMimeTypeApplicationOctetStream; extern NSString *const OWSMimeTypeImagePng; +extern NSString *const OWSMimeTypeOversizeTextMessage; @interface MIMETypeUtil : NSObject diff --git a/src/Util/MIMETypeUtil.m b/src/Util/MIMETypeUtil.m index bd1650203..1842e570d 100644 --- a/src/Util/MIMETypeUtil.m +++ b/src/Util/MIMETypeUtil.m @@ -12,6 +12,7 @@ NSString *const OWSMimeTypeApplicationOctetStream = @"application/octet-stream"; NSString *const OWSMimeTypeImagePng = @"image/png"; +NSString *const OWSMimeTypeOversizeTextMessage = @"text/x-signal-plain"; @implementation MIMETypeUtil @@ -291,6 +292,8 @@ NSString *const OWSMimeTypeImagePng = @"image/png"; return [MIMETypeUtil filePathForAnimated:uniqueId ofMIMEType:contentType inFolder:folder]; } else if ([self isBinaryData:contentType]) { return [MIMETypeUtil filePathForBinaryData:uniqueId ofMIMEType:contentType inFolder:folder]; + } else if ([contentType isEqualToString:OWSMimeTypeOversizeTextMessage]) { + return [MIMETypeUtil filePathForOversizeTextMessage:uniqueId inFolder:folder]; } DDLogError(@"Got asked for path of file %@ which is unsupported", contentType); @@ -344,6 +347,13 @@ NSString *const OWSMimeTypeImagePng = @"image/png"; stringByAppendingPathExtension:[self getSupportedExtensionFromBinaryDataMIMEType:contentType]]; } ++ (NSString *)filePathForOversizeTextMessage:(NSString *)uniqueId inFolder:(NSString *)folder { + // This file extension is arbitrary - it should never be exposed to the user or + // be used outside the app. + return [[folder stringByAppendingFormat:@"/%@", uniqueId] + stringByAppendingPathExtension:@"signal-text-message"]; +} + #if TARGET_OS_IPHONE + (NSString *)getSupportedImageMIMETypeFromImage:(UIImage *)image {