diff --git a/lib/media/media-utils.js b/lib/media/media-utils.js --- a/lib/media/media-utils.js +++ b/lib/media/media-utils.js @@ -14,7 +14,8 @@ if (media.length === 0) { return 'corrupted media'; } else if (media.length === 1) { - return `a ${media[0].type}`; + const type = media[0].type.replace('encrypted_', ''); + return `a ${type}`; } let firstType; for (const single of media) { @@ -28,6 +29,7 @@ } } invariant(firstType, 'there should be some media'); + firstType = firstType.replace('encrypted_', ''); if (firstType === 'photo') { firstType = 'image'; } diff --git a/lib/shared/messages/multimedia-message-spec.js b/lib/shared/messages/multimedia-message-spec.js --- a/lib/shared/messages/multimedia-message-spec.js +++ b/lib/shared/messages/multimedia-message-spec.js @@ -208,9 +208,19 @@ if (rawMessageInfo.type === messageTypes.IMAGES) { return rawMessageInfo; } - if (hasMinCodeVersion(platformDetails, 158)) { + + const containsEncryptedMedia = rawMessageInfo.media.some( + media => + media.type === 'encrypted_photo' || media.type === 'encrypted_video', + ); + if (!containsEncryptedMedia && hasMinCodeVersion(platformDetails, 158)) { return rawMessageInfo; } + // TODO: Change this when the version is known + if (hasMinCodeVersion(platformDetails, 1000)) { + return rawMessageInfo; + } + const { id } = rawMessageInfo; invariant(id !== null && id !== undefined, 'id should be set on server'); return { @@ -246,6 +256,7 @@ }; } else if (unwrapped.type === messageTypes.MULTIMEDIA) { for (const { type } of unwrapped.media) { + // TODO: add encrypted_photo and encrypted_video here when supported if (type !== 'photo' && type !== 'video') { return messageInfo; }