Changeset View
Changeset View
Standalone View
Standalone View
lib/shared/messages/multimedia-message-spec.js
Show First 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | > = Object.freeze({ | ||||
shimUnsupportedMessageInfo( | shimUnsupportedMessageInfo( | ||||
rawMessageInfo: RawMediaMessageInfo | RawImagesMessageInfo, | rawMessageInfo: RawMediaMessageInfo | RawImagesMessageInfo, | ||||
platformDetails: ?PlatformDetails, | platformDetails: ?PlatformDetails, | ||||
): RawMediaMessageInfo | RawImagesMessageInfo | RawUnsupportedMessageInfo { | ): RawMediaMessageInfo | RawImagesMessageInfo | RawUnsupportedMessageInfo { | ||||
if (rawMessageInfo.type === messageTypes.IMAGES) { | if (rawMessageInfo.type === messageTypes.IMAGES) { | ||||
return rawMessageInfo; | 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; | return rawMessageInfo; | ||||
} | } | ||||
// TODO: Change this when the version is known | |||||
if (hasMinCodeVersion(platformDetails, 1000)) { | |||||
return rawMessageInfo; | |||||
} | |||||
const { id } = rawMessageInfo; | const { id } = rawMessageInfo; | ||||
invariant(id !== null && id !== undefined, 'id should be set on server'); | invariant(id !== null && id !== undefined, 'id should be set on server'); | ||||
return { | return { | ||||
type: messageTypes.UNSUPPORTED, | type: messageTypes.UNSUPPORTED, | ||||
id, | id, | ||||
threadID: rawMessageInfo.threadID, | threadID: rawMessageInfo.threadID, | ||||
creatorID: rawMessageInfo.creatorID, | creatorID: rawMessageInfo.creatorID, | ||||
time: rawMessageInfo.time, | time: rawMessageInfo.time, | ||||
Show All 19 Lines | if (unwrapped.type === messageTypes.IMAGES) { | ||||
'only four photos were uploaded before dimensions were calculated, ' + | 'only four photos were uploaded before dimensions were calculated, ' + | ||||
`and ${media.id} was not one of them`, | `and ${media.id} was not one of them`, | ||||
); | ); | ||||
return { ...media, dimensions }; | return { ...media, dimensions }; | ||||
}), | }), | ||||
}; | }; | ||||
} else if (unwrapped.type === messageTypes.MULTIMEDIA) { | } else if (unwrapped.type === messageTypes.MULTIMEDIA) { | ||||
for (const { type } of unwrapped.media) { | for (const { type } of unwrapped.media) { | ||||
// TODO: add encrypted_photo and encrypted_video here when supported | |||||
if (type !== 'photo' && type !== 'video') { | if (type !== 'photo' && type !== 'video') { | ||||
return messageInfo; | return messageInfo; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return undefined; | return undefined; | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |