From e3b6c20f3b2a13bf645d6988c7bcb0ac61283323 Mon Sep 17 00:00:00 2001 From: Stef Coenen Date: Thu, 16 Nov 2023 14:54:29 +0100 Subject: [PATCH] Simplified upload file objects; Added base chat provider implementations; Base UI work for a chat screen; --- packages/chat-app/src/app/App.tsx | 6 +- .../src/hooks/chat/useChatMessages.ts | 23 ++ .../src/hooks/chat/useConversations.ts | 22 ++ .../chat-app/src/providers/ChatProvider.ts | 132 ++++++++++- .../src/providers/ConversationProvider.ts | 223 +++++++++++++++++- .../templates/Conversations/Conversations.tsx | 154 +++++++++++- .../src/hooks/auth/useDotYouClient.ts | 3 +- .../src/core/DriveData/File/DriveFileTypes.ts | 2 +- .../Upload/DriveFileUploadProvider.ts | 3 +- .../core/DriveData/Upload/DriveUploadTypes.ts | 12 +- .../core/DriveData/Upload/UploadHelpers.ts | 8 +- .../src/core/MediaData/ImageProvider.ts | 6 +- .../src/core/MediaData/VideoProvider.ts | 5 +- .../AttributeData/AttributeDataProvider.ts | 4 +- .../ProfileData/ProfileDefinitionProvider.ts | 6 +- .../public/posts/PostDefinitionProvider.ts | 2 +- .../src/public/posts/PostReactionProvider.ts | 2 +- .../owner-app/src/hooks/drives/useImport.ts | 5 +- .../src/provider/contact/ContactProvider.ts | 3 +- 19 files changed, 575 insertions(+), 46 deletions(-) create mode 100644 packages/chat-app/src/hooks/chat/useChatMessages.ts create mode 100644 packages/chat-app/src/hooks/chat/useConversations.ts diff --git a/packages/chat-app/src/app/App.tsx b/packages/chat-app/src/app/App.tsx index 6ad6ccfb9..e7b763915 100644 --- a/packages/chat-app/src/app/App.tsx +++ b/packages/chat-app/src/app/App.tsx @@ -11,7 +11,7 @@ import { import { Helmet, HelmetProvider } from 'react-helmet-async'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import Layout, { MinimalLayout } from '../components/ui/Layout/Layout'; +import Layout, { MinimalLayout, NoLayout } from '../components/ui/Layout/Layout'; const About = lazy(() => import('../templates/About/About')); const Auth = lazy(() => import('../templates/Auth/Auth')); @@ -53,9 +53,9 @@ function App() { path="" element={ - + - + } > diff --git a/packages/chat-app/src/hooks/chat/useChatMessages.ts b/packages/chat-app/src/hooks/chat/useChatMessages.ts new file mode 100644 index 000000000..c9a72bd88 --- /dev/null +++ b/packages/chat-app/src/hooks/chat/useChatMessages.ts @@ -0,0 +1,23 @@ +import { useDotYouClient } from '@youfoundation/common-app'; +import { useInfiniteQuery } from '@tanstack/react-query'; +import { getChatMessages } from '../../providers/ChatProvider'; + +const PAGE_SIZE = 100; +export const useChatMessages = ({ conversationId }: { conversationId: string | undefined }) => { + const dotYouClient = useDotYouClient().getDotYouClient(); + + const fetchMessages = async (conversationId: string, cursorState: string | undefined) => { + return await getChatMessages(dotYouClient, conversationId, cursorState, PAGE_SIZE); + }; + + return { + all: useInfiniteQuery({ + queryKey: ['chat', conversationId], + initialPageParam: undefined as string | undefined, + queryFn: ({ pageParam }) => fetchMessages(conversationId as string, pageParam), + getNextPageParam: (lastPage) => + lastPage.searchResults?.length >= PAGE_SIZE ? lastPage.cursorState : undefined, + enabled: !!conversationId, + }), + }; +}; diff --git a/packages/chat-app/src/hooks/chat/useConversations.ts b/packages/chat-app/src/hooks/chat/useConversations.ts new file mode 100644 index 000000000..0028004d0 --- /dev/null +++ b/packages/chat-app/src/hooks/chat/useConversations.ts @@ -0,0 +1,22 @@ +import { useDotYouClient } from '@youfoundation/common-app'; +import { getConversations } from '../../providers/ConversationProvider'; +import { useInfiniteQuery } from '@tanstack/react-query'; + +const PAGE_SIZE = 100; +export const useConversations = () => { + const dotYouClient = useDotYouClient().getDotYouClient(); + + const fetchConversations = async (cursorState: string | undefined) => { + return await getConversations(dotYouClient, cursorState, PAGE_SIZE); + }; + + return { + all: useInfiniteQuery({ + queryKey: ['conversations'], + initialPageParam: undefined as string | undefined, + queryFn: ({ pageParam }) => fetchConversations(pageParam), + getNextPageParam: (lastPage) => + lastPage.searchResults?.length >= PAGE_SIZE ? lastPage.cursorState : undefined, + }), + }; +}; diff --git a/packages/chat-app/src/providers/ChatProvider.ts b/packages/chat-app/src/providers/ChatProvider.ts index 733de0a05..458f6c277 100644 --- a/packages/chat-app/src/providers/ChatProvider.ts +++ b/packages/chat-app/src/providers/ChatProvider.ts @@ -1,5 +1,131 @@ -import { DotYouClient } from '@youfoundation/js-lib/core'; +import { + DotYouClient, + DriveSearchResult, + FileQueryParams, + GetBatchQueryResultOptions, + NewDriveSearchResult, + ScheduleOptions, + SecurityGroupType, + SendContents, + TargetDrive, + UploadFileMetadata, + UploadInstructionSet, + getContentFromHeaderOrPayload, + queryBatch, + uploadFile, +} from '@youfoundation/js-lib/core'; +import { ChatDrive, ChatMessage } from './ConversationProvider'; +import { jsonStringify64 } from '@youfoundation/js-lib/helpers'; -export const getChatMessages = (dotYouClient: DotYouClient, conversationId: string) => { - // ... +export const getChatMessages = async ( + dotYouClient: DotYouClient, + conversationId: string, + cursorState: string | undefined, + pageSize: number +) => { + const params: FileQueryParams = { + targetDrive: ChatDrive, + groupId: [conversationId], + }; + + const ro: GetBatchQueryResultOptions = { + maxRecords: pageSize, + cursorState: cursorState, + includeMetadataHeader: true, + }; + + const response = await queryBatch(dotYouClient, params, ro); + return { + ...response, + searchResults: await Promise.all( + response.searchResults.map( + async (result) => await dsrToMessage(dotYouClient, result, ChatDrive, true) + ) + ), + }; +}; + +export const dsrToMessage = async ( + dotYouClient: DotYouClient, + dsr: DriveSearchResult, + targetDrive: TargetDrive, + includeMetadataHeader: boolean +): Promise | null> => { + try { + const attrContent = await getContentFromHeaderOrPayload( + dotYouClient, + targetDrive, + dsr, + includeMetadataHeader + ); + if (!attrContent) return null; + + const chatMessage: DriveSearchResult = { + ...dsr, + fileMetadata: { + ...dsr.fileMetadata, + appData: { + ...dsr.fileMetadata.appData, + content: attrContent, + }, + }, + }; + + return chatMessage; + } catch (ex) { + console.error('[DotYouCore-js] failed to get the chatMessage payload of a dsr', dsr, ex); + return null; + } +}; + +export const uploadChatMessage = async ( + dotYouClient: DotYouClient, + message: NewDriveSearchResult, + onVersionConflict?: () => void +) => { + const messageContent = message.fileMetadata.appData.content; + + const uploadInstructions: UploadInstructionSet = { + storageOptions: { + drive: ChatDrive, + overwriteFileId: message.fileId, + }, + transitOptions: + messageContent.recipients?.length > 0 + ? { + recipients: messageContent.recipients, + schedule: ScheduleOptions.SendNowAwaitResponse, + sendContents: SendContents.All, + useGlobalTransitId: true, + } + : undefined, + }; + + messageContent.recipients = []; + const payloadJson: string = jsonStringify64({ ...messageContent }); + + const uploadMetadata: UploadFileMetadata = { + versionTag: message?.fileMetadata.versionTag, + allowDistribution: false, + appData: { + uniqueId: messageContent.id, + groupId: messageContent.conversationId, + fileType: messageContent.messageType, + content: payloadJson, + }, + isEncrypted: true, + accessControlList: message.serverMetadata?.accessControlList || { + requiredSecurityGroup: SecurityGroupType.Owner, + }, + }; + + return await uploadFile( + dotYouClient, + uploadInstructions, + uploadMetadata, + undefined, + undefined, + undefined, + onVersionConflict + ); }; diff --git a/packages/chat-app/src/providers/ConversationProvider.ts b/packages/chat-app/src/providers/ConversationProvider.ts index ae72fd42b..87f3cbab0 100644 --- a/packages/chat-app/src/providers/ConversationProvider.ts +++ b/packages/chat-app/src/providers/ConversationProvider.ts @@ -1,9 +1,222 @@ -import { DotYouClient } from '@youfoundation/js-lib/core'; +import { + DotYouClient, + DriveSearchResult, + FileQueryParams, + GetBatchQueryResultOptions, + NewDriveSearchResult, + SecurityGroupType, + TargetDrive, + UploadFileMetadata, + UploadInstructionSet, + getContentFromHeaderOrPayload, + getFileHeaderByUniqueId, + queryBatch, + uploadFile, +} from '@youfoundation/js-lib/core'; +import { jsonStringify64 } from '@youfoundation/js-lib/helpers'; -export const getConversations = (dotYouClient: DotYouClient) => { - // ... +export const ConversationFileType = 8888; +export const GroupConversationFileType = 8890; + +export const ChatDrive: TargetDrive = { + alias: '9ff813aff2d61e2f9b9db189e72d1a11', + type: '66ea8355ae4155c39b5a719166b510e3', }; -export const getConversation = (dotYouClient: DotYouClient, conversationId: string) => { - // ... +enum MessageType { + Text = 0, + Image = 1, + Video = 2, + Audio = 3, + File = 4, + Location = 5, + Sticker = 6, + Contact = 7, + Custom = 8, +} + +export interface ChatMessageContent { + text: string; + payload: string; // base64 encoded bytes? +} + +enum DeliveryStatus { + NotSent = 10, + Sending = 15, + Sent = 20, + Delivered = 30, + Read = 40, + Failed = 50, +} + +export interface ChatMessage { + // sender: string + + /// FileId of the message. Set on the server. Could be used as a uniqueId + // fileId: string + + /// ClientUniqueId. Set by the device + id: string; + + /// Timestamp when the message was created + receivedTimestamp: number; + + /// Timestamp when the message was updated + updatedTimestamp: number; + + /// GlobalTransitId of the payload. Same across all the recipients + globalTransitId: string; + + /// GroupId of the payload. + conversationId: string; + + /// ReplyId used to get the replyId of the message + replyId: string; + + /// Type of the message. It's the fileType from the server + messageType: MessageType; + + /// FileState of the Message + /// [FileState.active] shows the message is active + /// [FileState.deleted] shows the message is deleted. It's soft deleted + // fileState: FileState => archivalStatus + + /// Content of the message + message: ChatMessageContent; + + reactions: string; + + /// DeliveryStatus of the message. Indicates if the message is sent, delivered or read + deliveryStatus: DeliveryStatus; + + /// List of tags for the message + /// Could be used to assign tags to the message + /// E.g Could be a replyId + tags: string[]; + + /// List of recipients of the message that it is intended to be sent to. + recipients: string[]; +} + +export interface Conversation { + conversationId: string; + title: string; + imgId?: string; + messageType: MessageType; + recipient: string; + unread: boolean; + unreadCount: number; + message: ChatMessage; +} + +export const getConversations = async ( + dotYouClient: DotYouClient, + cursorState: string | undefined, + pageSize: number +) => { + const params: FileQueryParams = { + targetDrive: ChatDrive, + fileType: [ConversationFileType, GroupConversationFileType], + }; + + const ro: GetBatchQueryResultOptions = { + maxRecords: pageSize, + cursorState: cursorState, + includeMetadataHeader: true, + }; + + const response = await queryBatch(dotYouClient, params, ro); + + return { + ...response, + searchResults: await Promise.all( + response.searchResults.map( + async (result) => await dsrToConversation(dotYouClient, result, ChatDrive, true) + ) + ), + }; +}; + +export const getConversation = async (dotYouClient: DotYouClient, conversationId: string) => { + const conversationHeader = await getFileHeaderByUniqueId( + dotYouClient, + ChatDrive, + conversationId + ); + if (!conversationHeader) return null; + + return conversationHeader; +}; + +export const dsrToConversation = async ( + dotYouClient: DotYouClient, + dsr: DriveSearchResult, + targetDrive: TargetDrive, + includeMetadataHeader: boolean +): Promise | null> => { + try { + const attrContent = await getContentFromHeaderOrPayload( + dotYouClient, + targetDrive, + dsr, + includeMetadataHeader + ); + if (!attrContent) return null; + + const conversation: DriveSearchResult = { + ...dsr, + fileMetadata: { + ...dsr.fileMetadata, + appData: { + ...dsr.fileMetadata.appData, + content: attrContent, + }, + }, + }; + + return conversation; + } catch (ex) { + console.error('[DotYouCore-js] failed to get the conversation payload of a dsr', dsr, ex); + return null; + } +}; + +export const uploadConversation = async ( + dotYouClient: DotYouClient, + conversation: NewDriveSearchResult, + onVersionConflict?: () => void +) => { + const uploadInstructions: UploadInstructionSet = { + storageOptions: { + drive: ChatDrive, + overwriteFileId: conversation.fileId, + }, + }; + + const conversationContent = conversation.fileMetadata.appData.content; + const payloadJson: string = jsonStringify64({ ...conversationContent }); + + const uploadMetadata: UploadFileMetadata = { + versionTag: conversation?.fileMetadata.versionTag, + allowDistribution: false, + appData: { + uniqueId: conversationContent.conversationId, + fileType: conversation.fileMetadata.appData.fileType || ConversationFileType, + content: payloadJson, + }, + isEncrypted: true, + accessControlList: conversation.serverMetadata?.accessControlList || { + requiredSecurityGroup: SecurityGroupType.Owner, + }, + }; + + return await uploadFile( + dotYouClient, + uploadInstructions, + uploadMetadata, + undefined, + undefined, + undefined, + onVersionConflict + ); }; diff --git a/packages/chat-app/src/templates/Conversations/Conversations.tsx b/packages/chat-app/src/templates/Conversations/Conversations.tsx index 7ca66cbd5..470de7994 100644 --- a/packages/chat-app/src/templates/Conversations/Conversations.tsx +++ b/packages/chat-app/src/templates/Conversations/Conversations.tsx @@ -1,5 +1,153 @@ -const Conversations = () => { - return <>; +import { + ActionButton, + ConnectionImage, + ConnectionName, + EmojiSelector, + FileSelector, + ImageIcon, + Input, + OwnerName, + VolatileInput, + t, + useDotYouClient, + useSiteData, +} from '@youfoundation/common-app'; +import { useConversations } from '../../hooks/chat/useConversations'; +import { DriveSearchResult } from '@youfoundation/js-lib/core'; +import { Conversation } from '../../providers/ConversationProvider'; +import { useEffect, useState } from 'react'; +import { OdinImage } from '@youfoundation/ui-lib'; +import { HomePageConfig } from '@youfoundation/js-lib/public'; +import { BuiltInProfiles, GetTargetDriveFromProfileId } from '@youfoundation/js-lib/profile'; + +const ConversationsOverview = () => { + return ( +
+
+ + +
+
+ +
+
+ ); +}; + +const ProfileHeader = () => { + const { data } = useSiteData(); + const { getIdentity, getDotYouClient } = useDotYouClient(); + const dotYouClient = getDotYouClient(); + const odinId = getIdentity() || undefined; + + return ( +
+ + +
+ ); +}; + +const ConversationsList = () => { + const [isSearchActive, setIsSearchActive] = useState(false); + const { data: conversations } = useConversations().all; + + const flatConversaions = + (conversations?.pages + ?.flatMap((page) => page.searchResults) + ?.filter(Boolean) as DriveSearchResult[]) || []; + + return ( +
+ +
+ {flatConversaions?.map((conversation) => ( + + ))} +
+
+ ); +}; + +const ConversationItem = ({ conversation }: { conversation: DriveSearchResult }) => { + return <>{conversation.fileMetadata.appData.content.conversationId}; +}; + +const SearchConversation = ({ + setIsSearchActive, +}: { + setIsSearchActive: (isActive: boolean) => void; +}) => { + const [query, setQuery] = useState(undefined); + + useEffect(() => { + if (query && query.length > 1) setIsSearchActive(true); + else setIsSearchActive(false); + }, [query]); + + return ( +
e.preventDefault()}> +
+ setQuery(e.target.value)} /> + {t('Search')} +
+
+ ); +}; + +const Chat = ({ conversationId }: { conversationId: string }) => { + return ( +
+ + + +
+ ); +}; + +const ChatHeader = () => { + return ( +
+ + +
+ ); +}; + +const ChatHistory = () => { + return
; +}; + +const ChatComposer = () => { + return ( +
+
+ console.log(val)} + /> + setAttachment(newFiles?.[0])} + className="text-foreground text-opacity-30 hover:text-opacity-100" + > + + +
+ + {t('Send')} +
+ ); }; -export default Conversations; +export default ConversationsOverview; diff --git a/packages/common-app/src/hooks/auth/useDotYouClient.ts b/packages/common-app/src/hooks/auth/useDotYouClient.ts index 16aa4e647..db8f22b4f 100644 --- a/packages/common-app/src/hooks/auth/useDotYouClient.ts +++ b/packages/common-app/src/hooks/auth/useDotYouClient.ts @@ -15,7 +15,8 @@ export const useDotYouClient = () => { const _app = window.location.pathname.startsWith(OWNER_ROOT) ? 'owner' : window.location.hostname === 'dev.dotyou.cloud' || - window.location.hostname === 'feed.homebase.id' + window.location.hostname === 'feed.homebase.id' || + window.location.hostname === 'chat.homebase.id' ? 'apps' : 'home'; diff --git a/packages/js-lib/src/core/DriveData/File/DriveFileTypes.ts b/packages/js-lib/src/core/DriveData/File/DriveFileTypes.ts index 22e7cddd3..d06997b84 100644 --- a/packages/js-lib/src/core/DriveData/File/DriveFileTypes.ts +++ b/packages/js-lib/src/core/DriveData/File/DriveFileTypes.ts @@ -68,7 +68,7 @@ export interface AppFileMetaData { dataType: number; groupId?: string; userDate?: number; - tags: string[] | null; + tags?: string[]; uniqueId?: string; content: T; previewThumbnail?: EmbeddedThumb; diff --git a/packages/js-lib/src/core/DriveData/Upload/DriveFileUploadProvider.ts b/packages/js-lib/src/core/DriveData/Upload/DriveFileUploadProvider.ts index 587c2231e..ac94c15c0 100644 --- a/packages/js-lib/src/core/DriveData/Upload/DriveFileUploadProvider.ts +++ b/packages/js-lib/src/core/DriveData/Upload/DriveFileUploadProvider.ts @@ -18,6 +18,7 @@ import { buildManifest, } from './UploadHelpers'; import { getFileHeader, getPayloadBytes, getThumbBytes } from '../File/DriveFileProvider'; +import { getRandom16ByteArray } from '../../../helpers/DataUtil'; const isDebug = hasDebugFlag(); @@ -114,7 +115,7 @@ export const uploadHeader = async ( { fileMetadata: encryptedMetaData, }, - instructions.transferIv + instructions.transferIv || getRandom16ByteArray() ); const data = await buildFormData( diff --git a/packages/js-lib/src/core/DriveData/Upload/DriveUploadTypes.ts b/packages/js-lib/src/core/DriveData/Upload/DriveUploadTypes.ts index bb40f2a66..537fdd393 100644 --- a/packages/js-lib/src/core/DriveData/Upload/DriveUploadTypes.ts +++ b/packages/js-lib/src/core/DriveData/Upload/DriveUploadTypes.ts @@ -11,9 +11,9 @@ import { } from '../File/DriveFileTypes'; export interface UploadInstructionSet { - transferIv: Uint8Array; storageOptions: StorageOptions | null; - transitOptions: TransitOptions | null; + transitOptions?: TransitOptions; + transferIv?: Uint8Array; systemFileType?: SystemFileType; } @@ -27,8 +27,8 @@ export interface AppendInstructionSet { export interface StorageOptions { drive: TargetDrive; - overwriteFileId?: string | null; - expiresTimestamp?: number | null; + overwriteFileId?: string; + expiresTimestamp?: number; storageIntent?: 'metadataOnly'; // 'overwrite' is default } @@ -74,13 +74,13 @@ export interface UploadManifest { export interface UploadAppFileMetaData { uniqueId?: string; - tags: string[] | null; + tags?: string[]; fileType?: number; dataType?: number; userDate?: number; groupId?: string; archivalStatus?: ArchivalStatus; - content: string | null; + content?: string; previewThumbnail?: EmbeddedThumb; } diff --git a/packages/js-lib/src/core/DriveData/Upload/UploadHelpers.ts b/packages/js-lib/src/core/DriveData/Upload/UploadHelpers.ts index ed79fac9f..3b411aeb8 100644 --- a/packages/js-lib/src/core/DriveData/Upload/UploadHelpers.ts +++ b/packages/js-lib/src/core/DriveData/Upload/UploadHelpers.ts @@ -64,7 +64,7 @@ export const encryptMetaData = async ( ? uint8ArrayToBase64( await encryptWithKeyheader(stringToUint8Array(metadata.appData.content), keyHeader) ) - : null, + : undefined, }, } : metadata; @@ -95,17 +95,19 @@ export const buildDescriptor = async ( instructions: UploadInstructionSet | TransitInstructionSet, metadata: UploadFileMetadata ): Promise => { + const transferIv = instructions.transferIv ?? getRandom16ByteArray(); + return await encryptWithSharedSecret( dotYouClient, { encryptedKeyHeader: await encryptKeyHeader( dotYouClient, keyHeader ?? EMPTY_KEY_HEADER, - instructions.transferIv + transferIv ), fileMetadata: await encryptMetaData(metadata, keyHeader), }, - instructions.transferIv + transferIv ); }; diff --git a/packages/js-lib/src/core/MediaData/ImageProvider.ts b/packages/js-lib/src/core/MediaData/ImageProvider.ts index 2a34ad92d..abf53a63b 100644 --- a/packages/js-lib/src/core/MediaData/ImageProvider.ts +++ b/packages/js-lib/src/core/MediaData/ImageProvider.ts @@ -54,10 +54,10 @@ export const uploadImage = async ( const instructionSet: UploadInstructionSet = { transferIv: getRandom16ByteArray(), storageOptions: { - overwriteFileId: uploadMeta?.fileId ?? null, + overwriteFileId: uploadMeta?.fileId, drive: targetDrive, }, - transitOptions: uploadMeta?.transitOptions || null, + transitOptions: uploadMeta?.transitOptions, }; const { tinyThumb, additionalThumbnails } = await createThumbnails( @@ -85,7 +85,7 @@ export const uploadImage = async ( : [], uniqueId: uploadMeta?.uniqueId ?? getNewId(), fileType: MediaConfig.MediaFileType, - content: fileMetadata ? jsonStringify64(fileMetadata) : null, + content: fileMetadata ? jsonStringify64(fileMetadata) : undefined, previewThumbnail: tinyThumb, userDate: uploadMeta?.userDate, archivalStatus: uploadMeta?.archivalStatus, diff --git a/packages/js-lib/src/core/MediaData/VideoProvider.ts b/packages/js-lib/src/core/MediaData/VideoProvider.ts index 1e49c198d..49184ac69 100644 --- a/packages/js-lib/src/core/MediaData/VideoProvider.ts +++ b/packages/js-lib/src/core/MediaData/VideoProvider.ts @@ -54,10 +54,10 @@ export const uploadVideo = async ( const instructionSet: UploadInstructionSet = { transferIv: getRandom16ByteArray(), storageOptions: { - overwriteFileId: uploadMeta?.fileId ?? null, + overwriteFileId: uploadMeta?.fileId, drive: targetDrive, }, - transitOptions: uploadMeta?.transitOptions || null, + transitOptions: uploadMeta?.transitOptions, }; const { tinyThumb, additionalThumbnails } = uploadMeta?.thumb @@ -75,7 +75,6 @@ export const uploadVideo = async ( : [], uniqueId: uploadMeta?.uniqueId ?? getNewId(), fileType: 0, - content: null, userDate: uploadMeta?.userDate, previewThumbnail: tinyThumb, }, diff --git a/packages/js-lib/src/profile/AttributeData/AttributeDataProvider.ts b/packages/js-lib/src/profile/AttributeData/AttributeDataProvider.ts index b9d267807..848559188 100644 --- a/packages/js-lib/src/profile/AttributeData/AttributeDataProvider.ts +++ b/packages/js-lib/src/profile/AttributeData/AttributeDataProvider.ts @@ -396,7 +396,6 @@ export const saveAttribute = async ( overwriteFileId: toSaveAttribute?.fileId ?? '', drive: targetDrive, }, - transitOptions: null, }; const payloadJson: string = jsonStringify64(attrContent); @@ -418,7 +417,7 @@ export const saveAttribute = async ( tags: [attrContent.type, attrContent.sectionId, attrContent.profileId, attrContent.id], groupId: attrContent.sectionId, fileType: AttributeConfig.AttributeFileType, - content: shouldEmbedContent ? payloadJson : null, + content: shouldEmbedContent ? payloadJson : undefined, previewThumbnail: previewThumb || toSaveAttribute.fileMetadata.appData.previewThumbnail, }, isEncrypted: encrypt, @@ -474,7 +473,6 @@ export const saveAttribute = async ( overwriteFileId: toSaveAttribute.fileId, drive: targetDrive, }, - transitOptions: null, }; metadata.versionTag = runningVersionTag || metadata.versionTag; diff --git a/packages/js-lib/src/profile/ProfileData/ProfileDefinitionProvider.ts b/packages/js-lib/src/profile/ProfileData/ProfileDefinitionProvider.ts index b5c810a33..60e292346 100644 --- a/packages/js-lib/src/profile/ProfileData/ProfileDefinitionProvider.ts +++ b/packages/js-lib/src/profile/ProfileData/ProfileDefinitionProvider.ts @@ -119,7 +119,6 @@ export const saveProfileDefinition = async ( overwriteFileId: fileId?.toString(), drive: targetDrive, }, - transitOptions: null, }; const payloadJson: string = jsonStringify64(definition); @@ -136,7 +135,7 @@ export const saveProfileDefinition = async ( tags: [definition.profileId], fileType: ProfileConfig.ProfileDefinitionFileType, dataType: undefined, - content: shouldEmbedContent ? payloadJson : null, + content: shouldEmbedContent ? payloadJson : undefined, }, isEncrypted: encrypt, accessControlList: { requiredSecurityGroup: SecurityGroupType.Owner }, @@ -187,7 +186,6 @@ export const saveProfileSection = async ( overwriteFileId: fileId ?? undefined, drive: targetDrive, }, - transitOptions: null, }; const payloadJson: string = jsonStringify64(profileSection); @@ -205,7 +203,7 @@ export const saveProfileSection = async ( groupId: profileId, fileType: ProfileConfig.ProfileSectionFileType, dataType: undefined, - content: shouldEmbedContent ? payloadJson : null, + content: shouldEmbedContent ? payloadJson : undefined, }, isEncrypted: encrypt, accessControlList: { requiredSecurityGroup: SecurityGroupType.Owner }, diff --git a/packages/js-lib/src/public/posts/PostDefinitionProvider.ts b/packages/js-lib/src/public/posts/PostDefinitionProvider.ts index 3cf773904..6ea9d0bca 100644 --- a/packages/js-lib/src/public/posts/PostDefinitionProvider.ts +++ b/packages/js-lib/src/public/posts/PostDefinitionProvider.ts @@ -155,7 +155,7 @@ export const saveChannelDefinition = async ( appData: { tags: [definition.channelId], fileType: BlogConfig.ChannelDefinitionFileType, - content: shouldEmbedContent ? payloadJson : null, + content: shouldEmbedContent ? payloadJson : undefined, }, isEncrypted: encrypt, accessControlList: definition.acl, diff --git a/packages/js-lib/src/public/posts/PostReactionProvider.ts b/packages/js-lib/src/public/posts/PostReactionProvider.ts index 0608c6dc1..d6b72df4c 100644 --- a/packages/js-lib/src/public/posts/PostReactionProvider.ts +++ b/packages/js-lib/src/public/posts/PostReactionProvider.ts @@ -87,7 +87,7 @@ export const saveComment = async ( tags: [], uniqueId: comment.id ?? getNewId(), fileType: ReactionConfig.CommentFileType, - content: shouldEmbedContent ? payloadJson : null, + content: shouldEmbedContent ? payloadJson : undefined, previewThumbnail: previewThumbnail, userDate: comment.date ?? new Date().getTime(), }, diff --git a/packages/owner-app/src/hooks/drives/useImport.ts b/packages/owner-app/src/hooks/drives/useImport.ts index 563a7c2e6..c03080840 100644 --- a/packages/owner-app/src/hooks/drives/useImport.ts +++ b/packages/owner-app/src/hooks/drives/useImport.ts @@ -88,13 +88,12 @@ export const useImport = () => { overwriteFileId: overwriteFileId, drive: targetDrive, }, - transitOptions: null, }; const payloadJson = file.fileMetadata.contentType === 'application/json' ? jsonStringify64(file.payload) - : null; + : undefined; const payloadBytes = payloadJson ? stringToUint8Array(payloadJson) @@ -108,7 +107,7 @@ export const useImport = () => { accessControlList: file.fileMetadata.accessControlList, appData: { ...file.fileMetadata.appData, - content: shouldEmbedContent ? payloadJson : null, + content: shouldEmbedContent ? payloadJson : undefined, }, }; diff --git a/packages/owner-app/src/provider/contact/ContactProvider.ts b/packages/owner-app/src/provider/contact/ContactProvider.ts index b3e98a6db..a2cbba074 100644 --- a/packages/owner-app/src/provider/contact/ContactProvider.ts +++ b/packages/owner-app/src/provider/contact/ContactProvider.ts @@ -73,7 +73,6 @@ export const saveContact = async ( overwriteFileId: contact?.fileId ?? '', drive: ContactConfig.ContactTargetDrive, }, - transitOptions: null, }; const payloadJson: string = jsonStringify64({ @@ -95,7 +94,7 @@ export const saveContact = async ( appData: { tags: tags, fileType: ContactConfig.ContactFileType, - content: shouldEmbedContent ? payloadJson : null, + content: shouldEmbedContent ? payloadJson : undefined, // Having the odinId MD5 hashed as unique id, avoids having duplicates getting created, enforced server-side; uniqueId: contact.odinId ? toGuidId(contact.odinId) : contact.id, previewThumbnail: previewThumb,