Page MenuHomePhabricator

D7235.diff
No OneTemporary

D7235.diff

diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js
--- a/lib/reducers/message-reducer.js
+++ b/lib/reducers/message-reducer.js
@@ -1236,6 +1236,57 @@
) {
media.push({ ...singleMedia, ...mediaUpdate });
replaced = true;
+ } else if (
+ singleMedia.type === 'photo' &&
+ mediaUpdate.type === 'encrypted_photo'
+ ) {
+ // extract fields that are absent in encrypted_photo type
+ const { uri, localMediaSelection, ...original } = singleMedia;
+ const { holder, encryptionKey, ...update } = mediaUpdate;
+ invariant(
+ holder && encryptionKey,
+ 'holder and encryptionKey are required for encrypted_photo message',
+ );
+ media.push({
+ ...original,
+ ...update,
+ type: 'encrypted_photo',
+ holder,
+ encryptionKey,
+ });
+ replaced = true;
+ } else if (
+ singleMedia.type === 'video' &&
+ mediaUpdate.type === 'encrypted_video'
+ ) {
+ const { uri, thumbnailURI, localMediaSelection, ...original } =
+ singleMedia;
+ const {
+ holder,
+ encryptionKey,
+ thumbnailHolder,
+ thumbnailEncryptionKey,
+ ...update
+ } = mediaUpdate;
+ invariant(
+ holder && encryptionKey,
+ 'holder and encryptionKey are required for encrypted_video message',
+ );
+ invariant(
+ thumbnailHolder && thumbnailEncryptionKey,
+ 'thumbnailHolder and thumbnailEncryptionKey are required for ' +
+ 'encrypted_video message',
+ );
+ media.push({
+ ...original,
+ ...update,
+ type: 'encrypted_video',
+ holder,
+ encryptionKey,
+ thumbnailHolder,
+ thumbnailEncryptionKey,
+ });
+ replaced = true;
}
}
updatedMessage = { ...message, media };

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 9:42 AM (18 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2694391
Default Alt Text
D7235.diff (2 KB)

Event Timeline