diff --git a/lib/shared/threads/protocols/dm-thread-protocol.js b/lib/shared/threads/protocols/dm-thread-protocol.js --- a/lib/shared/threads/protocols/dm-thread-protocol.js +++ b/lib/shared/threads/protocols/dm-thread-protocol.js @@ -480,6 +480,8 @@ chatThreadListIcon: 'lock', breadCrumbs: () => 'Local DM', }, + + uploadMultimediaMetadataToKeyserver: false, }); export { dmThreadProtocol }; diff --git a/lib/shared/threads/protocols/keyserver-thread-protocol.js b/lib/shared/threads/protocols/keyserver-thread-protocol.js --- a/lib/shared/threads/protocols/keyserver-thread-protocol.js +++ b/lib/shared/threads/protocols/keyserver-thread-protocol.js @@ -297,6 +297,8 @@ chatThreadListIcon: 'server', breadCrumbs: (ancestorPath: React.Node) => ancestorPath, }, + + uploadMultimediaMetadataToKeyserver: true, }); function mediaIDIsKeyserverID(mediaID: string): boolean { diff --git a/lib/shared/threads/thread-spec.js b/lib/shared/threads/thread-spec.js --- a/lib/shared/threads/thread-spec.js +++ b/lib/shared/threads/thread-spec.js @@ -213,6 +213,7 @@ +chatThreadListIcon: string, +breadCrumbs: (ancestorPath: React.Node) => React.Node, }, + +uploadMultimediaMetadataToKeyserver: boolean, }; export type ThreadSpec = { 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 @@ -15,6 +15,7 @@ extensionFromFilename, filenameFromPathOrURI, } from 'lib/media/file-utils.js'; +import { threadSpecs } from 'lib/shared/threads/thread-specs.js'; import type { UpdateUserAvatarRequest } from 'lib/types/avatar-types.js'; import type { NativeMediaSelection, @@ -25,7 +26,6 @@ RawThreadInfo, ThreadInfo, } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import { threadTypeIsThick } from 'lib/types/thread-types-enum.js'; import { authoritativeKeyserverID } from '../authoritative-keyserver.js'; import CommIcon from '../components/comm-icon.react.js'; @@ -400,9 +400,10 @@ selection: NativeMediaSelection, threadInfo: ThreadInfo | RawThreadInfo, ): Promise => { - const metadataUploadLocation = threadTypeIsThick(threadInfo.type) - ? 'none' - : 'keyserver'; + const metadataUploadLocation = threadSpecs[threadInfo.type].protocol + .uploadMultimediaMetadataToKeyserver + ? 'keyserver' + : 'none'; const imageAvatarUpdateRequest = await uploadSelectedMedia( selection, metadataUploadLocation, 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 @@ -51,7 +51,10 @@ threadIsPending, threadIsPendingSidebar, } from 'lib/shared/thread-utils.js'; -import { threadTypeIsSidebar } from 'lib/shared/threads/thread-specs.js'; +import { + threadSpecs, + threadTypeIsSidebar, +} from 'lib/shared/threads/thread-specs.js'; import type { CalendarQuery } from 'lib/types/entry-types.js'; import type { Media, @@ -852,14 +855,15 @@ uploadThumbnailResult, mediaMissionResult; - const isThickThread = threadTypeIsThick(threadInfo.type); try { invariant( processedMedia.mediaType === 'encrypted_photo' || processedMedia.mediaType === 'encrypted_video', 'uploaded media should be encrypted', ); - const uploadMetadataToKeyserver = !isThickThread; + const uploadMetadataToKeyserver = + threadSpecs[threadInfo.type].protocol + .uploadMultimediaMetadataToKeyserver; const uploadPromise = this.props.blobServiceUpload({ uploadInput: { blobInput: { 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 @@ -7,12 +7,12 @@ import { useModalContext } from 'lib/components/modal-provider.react.js'; import SWMansionIcon from 'lib/components/swmansion-icon.react.js'; import { getCommunity } from 'lib/shared/thread-utils.js'; +import { threadSpecs } from 'lib/shared/threads/thread-specs.js'; import type { CommunityInfo } from 'lib/types/community-types.js'; import type { 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'; @@ -72,7 +72,8 @@ ); const uploadAvatarMedia = useUploadAvatarMedia({ - uploadMetadataToKeyserver: !threadTypeIsThick(threadInfo.type), + uploadMetadataToKeyserver: + threadSpecs[threadInfo.type].protocol.uploadMultimediaMetadataToKeyserver, }); const onImageSelected = React.useCallback( async (event: SyntheticEvent) => { 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 @@ -53,7 +53,10 @@ threadIsPending, threadIsPendingSidebar, } from 'lib/shared/thread-utils.js'; -import { threadTypeIsSidebar } from 'lib/shared/threads/thread-specs.js'; +import { + threadSpecs, + threadTypeIsSidebar, +} from 'lib/shared/threads/thread-specs.js'; import type { CalendarQuery } from 'lib/types/entry-types.js'; import type { MediaMission, @@ -868,7 +871,8 @@ async uploadFile(threadInfo: ThreadInfo, upload: PendingMultimediaUpload) { const { selectTime, localID, encryptionKey } = upload; const threadID = threadInfo.id; - const isThickThread = threadTypeIsThick(threadInfo.type); + const uploadMultimediaMetadataToKeyserver = + threadSpecs[threadInfo.type].protocol.uploadMultimediaMetadataToKeyserver; const isEncrypted = !!encryptionKey && (upload.mediaType === 'encrypted_photo' || @@ -933,7 +937,9 @@ loop: false, thumbHash, }, - keyserverOrThreadID: isThickThread ? null : threadID, + keyserverOrThreadID: uploadMultimediaMetadataToKeyserver + ? threadID + : null, callbacks, }); } catch (e) { @@ -1007,10 +1013,10 @@ serverID: result.id, blobHolder: result.blobHolder, abort: null, - // For thin threads we can send message right after serverID - // is present, but for thick threads we need to wait until + // When we upload files to a keyserver, we can send message right + // after serverID is present, otherwise we need to wait until // a "real" Blob URI is assigned to the message. - canBeSent: !isThickThread, + canBeSent: uploadMultimediaMetadataToKeyserver, }, }, }, @@ -1207,7 +1213,10 @@ } if (pendingUpload.serverID) { const { serverID } = pendingUpload; - if (!threadTypeIsThick(threadInfo.type)) { + if ( + threadSpecs[threadInfo.type].protocol + .uploadMultimediaMetadataToKeyserver + ) { void this.props.deleteUpload({ id: serverID, keyserverOrThreadID: threadInfo.id,