diff --git a/packages/apps/community-app/src/hooks/community/live/useCommunityPeerWebsocket.ts b/packages/apps/community-app/src/hooks/community/live/useCommunityPeerWebsocket.ts index ac6ab5d64..8b5bdbe0d 100644 --- a/packages/apps/community-app/src/hooks/community/live/useCommunityPeerWebsocket.ts +++ b/packages/apps/community-app/src/hooks/community/live/useCommunityPeerWebsocket.ts @@ -50,7 +50,6 @@ export const useCommunityPeerWebsocket = ( return; } isDebug && console.debug('[PeerCommunityWebsocket] Got notification', notification); - if ( (notification.notificationType === 'fileAdded' || notification.notificationType === 'fileModified' || diff --git a/packages/apps/community-app/src/hooks/community/messages/useCommunityMessage.ts b/packages/apps/community-app/src/hooks/community/messages/useCommunityMessage.ts index a5ca4abe2..0bd198ead 100644 --- a/packages/apps/community-app/src/hooks/community/messages/useCommunityMessage.ts +++ b/packages/apps/community-app/src/hooks/community/messages/useCommunityMessage.ts @@ -154,6 +154,9 @@ export const useCommunityMessage = (props?: { newChat.fileMetadata.appData.previewThumbnail = uploadResult.previewThumbnail; newChat.fileMetadata.appData.content.deliveryStatus = CommunityDeliveryStatus.Sent; + // We force set the keyHeader as it's returned from the upload, and needed for fast saves afterwards + // eslint-disable-next-line @typescript-eslint/no-explicit-any + newChat.sharedSecretEncryptedKeyHeader = uploadResult.keyHeader as any; return newChat; }; @@ -268,6 +271,7 @@ export const useCommunityMessage = (props?: { }, payloads: msg?.fileMetadata.payloads, }, + sharedSecretEncryptedKeyHeader: newMessage.sharedSecretEncryptedKeyHeader, }; } diff --git a/packages/common/common-app/src/hooks/socialFeed/article/useArticleComposer.ts b/packages/common/common-app/src/hooks/socialFeed/article/useArticleComposer.ts index a5cb3ae48..82696f91c 100644 --- a/packages/common/common-app/src/hooks/socialFeed/article/useArticleComposer.ts +++ b/packages/common/common-app/src/hooks/socialFeed/article/useArticleComposer.ts @@ -208,7 +208,7 @@ export const useArticleComposer = ({ }, versionTag: (uploadResult as UploadResult).newVersionTag, }, - // We force set the keyHeader as it's returned from the server, and needed for fast saves afterwards + // We force set the keyHeader as it's returned from the upload, and needed for fast saves afterwards // eslint-disable-next-line @typescript-eslint/no-explicit-any sharedSecretEncryptedKeyHeader: (uploadResult as UploadResult).keyHeader as any, }; diff --git a/packages/libs/js-lib/src/peer/peerData/PeerTypes.ts b/packages/libs/js-lib/src/peer/peerData/PeerTypes.ts index 0239c259a..07625ecdd 100644 --- a/packages/libs/js-lib/src/peer/peerData/PeerTypes.ts +++ b/packages/libs/js-lib/src/peer/peerData/PeerTypes.ts @@ -6,7 +6,7 @@ import { ScheduleOptions, TransferUploadStatus, } from '../../core/DriveData/Upload/DriveUploadTypes'; -import { TargetDrive } from '../../core/core'; +import { KeyHeader, TargetDrive } from '../../core/core'; export interface TransitQueryBatchRequest { queryParams: FileQueryParams; @@ -34,4 +34,5 @@ export interface TransitUploadResult { globalTransitId: string; targetDrive: TargetDrive; }; + keyHeader: KeyHeader | undefined; } diff --git a/packages/libs/js-lib/src/peer/peerData/Upload/PeerFileUploader.ts b/packages/libs/js-lib/src/peer/peerData/Upload/PeerFileUploader.ts index 11818d116..fbb1f6429 100644 --- a/packages/libs/js-lib/src/peer/peerData/Upload/PeerFileUploader.ts +++ b/packages/libs/js-lib/src/peer/peerData/Upload/PeerFileUploader.ts @@ -42,7 +42,7 @@ export const uploadFileOverPeer = async ( aesKey?: Uint8Array | undefined; axiosConfig?: AxiosRequestConfig; } -) => { +): Promise => { isDebug && console.debug( 'request', @@ -95,7 +95,7 @@ export const uploadFileOverPeer = async ( }, }; - const response = await client + const uploadResult = await client .post(url, data, config) .then((response) => { const recipientStatus = response.data.recipientStatus; @@ -116,10 +116,12 @@ export const uploadFileOverPeer = async ( console.debug( 'response', new URL(`${dotYouClient.getEndpoint()}/transit/sender/files/send'`).pathname, - response + uploadResult ); - return response; + if (!uploadResult) return; + uploadResult.keyHeader = keyHeader; + return uploadResult; }; export const uploadHeaderOverPeer = async ( diff --git a/packages/libs/js-lib/src/public/posts/Upload/PostUploader.ts b/packages/libs/js-lib/src/public/posts/Upload/PostUploader.ts index 17f019777..bb7f3bb71 100644 --- a/packages/libs/js-lib/src/public/posts/Upload/PostUploader.ts +++ b/packages/libs/js-lib/src/public/posts/Upload/PostUploader.ts @@ -213,7 +213,7 @@ const uploadPost = async ( recipients: [odinId], }; - const result: TransitUploadResult = await uploadFileOverPeer( + const result = await uploadFileOverPeer( dotYouClient, transitInstructionSet, metadata,