From 72e0d2c20a7ce0d5bf1a2be4c6b30813d0ecdc5e Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 27 Feb 2019 09:03:35 -0700 Subject: [PATCH] Only render visual media as album This check was enforced for AttachmentStreams, but not AttachmentPointers --- .../ConversationView/ConversationViewItem.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index 33424a478..8decd7c26 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -603,7 +603,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) } NSArray *mediaAttachments = [message mediaAttachmentsWithTransaction:transaction]; - NSArray *mediaAlbumItems = [self mediaAlbumItemsForAttachments:mediaAttachments]; + NSArray *mediaAlbumItems = [self albumItemsForMediaAttachments:mediaAttachments]; if (mediaAlbumItems.count > 0) { if (mediaAlbumItems.count == 1) { ConversationMediaAlbumItem *mediaAlbumItem = mediaAlbumItems.firstObject; @@ -686,12 +686,19 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) } } -- (NSArray *)mediaAlbumItemsForAttachments:(NSArray *)attachments +- (NSArray *)albumItemsForMediaAttachments:(NSArray *)attachments { OWSAssertIsOnMainThread(); NSMutableArray *mediaAlbumItems = [NSMutableArray new]; for (TSAttachment *attachment in attachments) { + if (!attachment.isVisualMedia) { + // Well behaving clients should not send a mix of visual media (like JPG) and non-visual media (like PDF's) + // Since we're not coped to handle a mix of media, return @[] + OWSAssertDebug(mediaAlbumItems.count == 0); + return @[]; + } + NSString *_Nullable caption = (attachment.caption ? [self displayableCaptionForText:attachment.caption attachmentId:attachment.uniqueId].displayText : nil);