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 @@ -17,7 +17,15 @@ // TODO: flip the switch const useBlobServiceUploads = false; -function useUploadAvatarMedia(): File => Promise { +type AvatarMediaUploadOptions = { + uploadMetadataToKeyserver?: boolean, +}; + +function useUploadAvatarMedia( + options: AvatarMediaUploadOptions = {}, +): File => Promise { + const { uploadMetadataToKeyserver = true } = options; + const callUploadMultimedia = useLegacyAshoatKeyserverCall(uploadMultimedia); const callBlobServiceUpload = useBlobServiceUpload(); const uploadAvatarMedia = React.useCallback( @@ -32,7 +40,9 @@ ...dimensions, loop: false, }; - if (!useBlobServiceUploads) { + const useBlobService = + !uploadMetadataToKeyserver || useBlobServiceUploads; + if (!useBlobService) { const { id } = await callUploadMultimedia(fixedFile, uploadExtras); return { type: 'image', uploadID: id }; } @@ -56,7 +66,7 @@ ? thumbHashResult.thumbHash : null; - const { id } = await callBlobServiceUpload({ + const { id, uri } = await callBlobServiceUpload({ uploadInput: { blobInput: { type: 'file', @@ -68,13 +78,24 @@ loop: false, thumbHash, }, - keyserverOrThreadID: authoritativeKeyserverID, + keyserverOrThreadID: uploadMetadataToKeyserver + ? authoritativeKeyserverID + : null, callbacks: {}, }); - return { type: 'encrypted_image', uploadID: id }; + if (uploadMetadataToKeyserver) { + return { type: 'encrypted_image', uploadID: id }; + } + + return { + type: 'thick_thread_image', + blobURI: uri, + thumbHash, + encryptionKey, + }; }, - [callBlobServiceUpload, callUploadMultimedia], + [callBlobServiceUpload, callUploadMultimedia, uploadMetadataToKeyserver], ); return uploadAvatarMedia; } diff --git a/web/avatars/edit-thread-avatar-menu.react.js b/web/avatars/edit-thread-avatar-menu.react.js --- a/web/avatars/edit-thread-avatar-menu.react.js +++ b/web/avatars/edit-thread-avatar-menu.react.js @@ -10,6 +10,7 @@ ThreadInfo, RawThreadInfo, } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import { threadTypeIsThick } from 'lib/types/thread-types-enum.js'; import { useUploadAvatarMedia } from './avatar-hooks.react.js'; import css from './edit-avatar-menu.css'; @@ -58,7 +59,9 @@ [], ); - const uploadAvatarMedia = useUploadAvatarMedia(); + const uploadAvatarMedia = useUploadAvatarMedia({ + uploadMetadataToKeyserver: !threadTypeIsThick(threadInfo.type), + }); const onImageSelected = React.useCallback( async (event: SyntheticEvent) => { const { target } = event;