diff --git a/native/avatars/avatar-hooks.js b/native/avatars/avatar-hooks.js --- a/native/avatars/avatar-hooks.js +++ b/native/avatars/avatar-hooks.js @@ -44,8 +44,6 @@ import blobServiceUploadHandler from '../utils/blob-service-upload.js'; import { useStaffCanSee } from '../utils/staff-utils.js'; -const useBlobServiceUploads = true; - function displayAvatarUpdateFailureAlert(): void { Alert.alert( 'Couldn’t save avatar', @@ -63,8 +61,7 @@ const callBlobServiceUpload = useBlobServiceUpload(); return React.useCallback( async (processedMedia, metadataUploadLocation) => { - const useBlobService = - metadataUploadLocation !== 'keyserver' || useBlobServiceUploads; + const useBlobService = metadataUploadLocation !== 'keyserver'; if (!useBlobService) { const { uploadURI, filename, mime, dimensions } = processedMedia; const { id } = await callUploadMultimedia( diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js --- a/native/input/input-state-container.react.js +++ b/native/input/input-state-container.react.js @@ -192,8 +192,6 @@ > = new Map(); pendingThreadUpdateHandlers: Map mixed> = new Map(); - useBlobServiceUploads = true; - // When the user sends a multimedia message that triggers the creation of a // sidebar, the sidebar gets created right away, but the message needs to wait // for the uploads to complete before sending. We use this Set to track the @@ -629,11 +627,6 @@ } } - // eslint-disable-next-line no-unused-vars - shouldEncryptMedia(threadInfo: ThreadInfo): boolean { - return true; - } - sendMultimediaMessage = async ( selections: $ReadOnlyArray, threadInfo: ThreadInfo, @@ -722,7 +715,7 @@ creatorID, media, }, - { forceMultimediaMessageType: this.shouldEncryptMedia(threadInfo) }, + { forceMultimediaMessageType: true }, ); this.props.dispatch({ type: createLocalMessageActionType, @@ -825,29 +818,27 @@ }); } - if (this.shouldEncryptMedia(threadInfo)) { - const encryptionStart = Date.now(); - try { - const { result: encryptionResult, ...encryptionReturn } = - await encryptMedia(processedMedia); - encryptionSteps = encryptionReturn.steps; - if (!encryptionResult.success) { - onUploadFailed(encryptionResult.reason); - return await onUploadFinished(encryptionResult); - } - if (encryptionResult.shouldDisposePath) { - filesToDispose.push(encryptionResult.shouldDisposePath); - } - processedMedia = encryptionResult; - } catch (e) { - onUploadFailed('encryption failed'); - return await onUploadFinished({ - success: false, - reason: 'encryption_exception', - time: Date.now() - encryptionStart, - exceptionMessage: getMessageForException(e), - }); + const encryptionStart = Date.now(); + try { + const { result: encryptionResult, ...encryptionReturn } = + await encryptMedia(processedMedia); + encryptionSteps = encryptionReturn.steps; + if (!encryptionResult.success) { + onUploadFailed(encryptionResult.reason); + return await onUploadFinished(encryptionResult); + } + if (encryptionResult.shouldDisposePath) { + filesToDispose.push(encryptionResult.shouldDisposePath); } + processedMedia = encryptionResult; + } catch (e) { + onUploadFailed('encryption failed'); + return await onUploadFinished({ + success: false, + reason: 'encryption_exception', + time: Date.now() - encryptionStart, + exceptionMessage: getMessageForException(e), + }); } const { uploadURI, filename, mime } = processedMedia; @@ -861,12 +852,10 @@ mediaMissionResult; const isThickThread = threadTypeIsThick(threadInfo.type); - const useBlobService = isThickThread || this.useBlobServiceUploads; try { if ( - useBlobService && - (processedMedia.mediaType === 'encrypted_photo' || - processedMedia.mediaType === 'encrypted_video') + processedMedia.mediaType === 'encrypted_photo' || + processedMedia.mediaType === 'encrypted_video' ) { const uploadMetadataToKeyserver = !isThickThread; const uploadPromise = this.props.blobServiceUpload({ @@ -941,7 +930,6 @@ processedMedia.mediaType === 'encrypted_video' ? processedMedia.loop : undefined, - encryptionKey: processedMedia.encryptionKey, thumbHash: processedMedia.mediaType === 'photo' || processedMedia.mediaType === 'encrypted_photo' diff --git a/web/avatars/avatar-hooks.react.js b/web/avatars/avatar-hooks.react.js --- a/web/avatars/avatar-hooks.react.js +++ b/web/avatars/avatar-hooks.react.js @@ -14,8 +14,6 @@ import { generateThumbHash } from '../media/image-utils.js'; import { validateFile } from '../media/media-utils.js'; -const useBlobServiceUploads = true; - type AvatarMediaUploadOptions = { +uploadMetadataToKeyserver?: boolean, }; @@ -39,9 +37,7 @@ ...dimensions, loop: false, }; - const useBlobService = - !uploadMetadataToKeyserver || useBlobServiceUploads; - if (!useBlobService) { + if (uploadMetadataToKeyserver) { const { id } = await callUploadMultimedia(fixedFile, uploadExtras); return { type: 'image', uploadID: id }; } diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -213,8 +213,6 @@ }>, >(); - useBlobServiceUploads = true; - // When the user sends a multimedia message that triggers the creation of a // sidebar, the sidebar gets created right away, but the message needs to wait // for the uploads to complete before sending. We use this Set to track the @@ -311,7 +309,6 @@ string, { +threadID: string, - +shouldEncrypt: boolean, +uploads: PendingMultimediaUpload[], }, >(); @@ -327,26 +324,18 @@ ) { continue; } - const { shouldEncrypt } = upload; let assignedUploads = newlyAssignedUploads.get(messageID); if (!assignedUploads) { - assignedUploads = { threadID, shouldEncrypt, uploads: [] }; + assignedUploads = { threadID, uploads: [] }; newlyAssignedUploads.set(messageID, assignedUploads); } - if (shouldEncrypt !== assignedUploads.shouldEncrypt) { - console.warn( - `skipping upload ${localUploadID} ` + - "because shouldEncrypt doesn't match", - ); - continue; - } assignedUploads.uploads.push(upload); } } const newMessageInfos = new Map(); for (const [messageID, assignedUploads] of newlyAssignedUploads) { - const { uploads, threadID, shouldEncrypt } = assignedUploads; + const { uploads, threadID } = assignedUploads; const creatorID = this.props.viewerID; invariant(creatorID, 'need viewer ID in order to send a message'); const media = uploads.map( @@ -401,7 +390,7 @@ creatorID, media, }, - { forceMultimediaMessageType: shouldEncrypt }, + { forceMultimediaMessageType: true }, ); newMessageInfos.set(messageID, messageInfo); } @@ -445,11 +434,6 @@ return rawMessageInfo; } - // eslint-disable-next-line no-unused-vars - shouldEncryptMedia(threadInfo: ThreadInfo): boolean { - return true; - } - async sendMultimediaMessage( messageInfo: RawMultimediaMessageInfo, ): Promise { @@ -817,29 +801,26 @@ } const { uri, file: fixedFile, mediaType, dimensions } = result; - const shouldEncrypt = this.shouldEncryptMedia(threadInfo); - - let encryptionResult; - if (shouldEncrypt) { - let encryptionResponse; - const encryptionStart = Date.now(); - try { - encryptionResponse = await encryptFile(fixedFile); - } catch (e) { - return { - steps, - result: { - success: false, - reason: 'encryption_exception', - time: Date.now() - encryptionStart, - exceptionMessage: getMessageForException(e), - }, - }; - } - steps.push(...encryptionResponse.steps); - encryptionResult = encryptionResponse.result; + let encryptionResponse; + const encryptionStart = Date.now(); + try { + encryptionResponse = await encryptFile(fixedFile); + } catch (e) { + return { + steps, + result: { + success: false, + reason: 'encryption_exception', + time: Date.now() - encryptionStart, + exceptionMessage: getMessageForException(e), + }, + }; } - if (encryptionResult && !encryptionResult.success) { + const { result: encryptionResult, steps: encryptionSteps } = + encryptionResponse; + steps.push(...encryptionSteps); + + if (!encryptionResult.success) { return { steps, result: encryptionResult }; } @@ -874,7 +855,6 @@ abort: null, steps, selectTime, - shouldEncrypt, }, }, }; @@ -934,11 +914,9 @@ abortHandler: (abort: () => void) => this.handleAbortCallback(threadID, localID, abort), }; - const useBlobService = isThickThread || this.useBlobServiceUploads; if ( - useBlobService && - (upload.mediaType === 'encrypted_photo' || - upload.mediaType === 'encrypted_video') + upload.mediaType === 'encrypted_photo' || + upload.mediaType === 'encrypted_video' ) { const { blobHash, dimensions, thumbHash } = upload; invariant( diff --git a/web/input/input-state.js b/web/input/input-state.js --- a/web/input/input-state.js +++ b/web/input/input-state.js @@ -42,7 +42,6 @@ +abort: ?() => void, +steps: MediaMissionStep[], +selectTime: number, - +shouldEncrypt: boolean, }; export type TypeaheadState = {