PR Feedback

This commit is contained in:
Nora Trapp 2020-09-23 14:52:33 -07:00
parent 9b33de1bde
commit af10d28fc3
3 changed files with 13 additions and 5 deletions

View File

@ -29,7 +29,7 @@ typedef NS_ENUM(NSUInteger, TSAttachmentType) {
@property (atomic) NSString *cdnKey;
@property (atomic) UInt32 cdnNumber;
@property (atomic, readwrite, nullable) NSData *encryptionKey;
@property (nonatomic) NSString *contentType;
@property (nonatomic, readonly) NSString *contentType;
@property (nonatomic) TSAttachmentType attachmentType;
// Though now required, may incorrectly be 0 on legacy attachments.
@ -141,6 +141,10 @@ NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:albumMessageId:atta
+ (NSString *)emojiForMimeType:(NSString *)contentType;
// This should only ever be used before the attachment is saved,
// after that point the content type will be already set.
- (void)setDefaultContentType:(NSString *)contentType;
#pragma mark - Update With...
- (void)updateWithBlurHash:(NSString *)blurHash transaction:(SDSAnyWriteTransaction *)transaction;

View File

@ -456,6 +456,13 @@ NSUInteger const TSAttachmentSchemaVersion = 5;
[self.attachmentReadCache didRemoveAttachment:self transaction:transaction];
}
- (void)setDefaultContentType:(NSString *)contentType
{
if ([self.contentType isEqualToString:OWSMimeTypeApplicationOctetStream]) {
_contentType = contentType;
}
}
#pragma mark - Update With...
- (void)updateWithBlurHash:(NSString *)blurHash transaction:(SDSAnyWriteTransaction *)transaction

View File

@ -154,10 +154,7 @@ public class MessageSticker: MTLModel {
throw StickerError.invalidInput
}
if dataProto.contentType?.isEmpty != false && attachmentPointer.contentType == OWSMimeTypeApplicationOctetStream {
Logger.warn("Assuming sticker is webp, received with unspecified content-type")
attachmentPointer.contentType = OWSMimeTypeImageWebp
}
attachmentPointer.setDefaultContentType(OWSMimeTypeImageWebp)
attachmentPointer.anyInsert(transaction: transaction)
return attachmentPointer