diff --git a/src/app/slices/message.ts b/src/app/slices/message.ts index 71969628..07a0ac15 100644 --- a/src/app/slices/message.ts +++ b/src/app/slices/message.ts @@ -9,7 +9,7 @@ export interface MessagePayload { created_at?: number; sending?: boolean; content_type: ContentType; - content: string; + content: string | { path: string }; expires_in?: number | null; properties?: { name?: string; diff --git a/src/common/hook/useSendMessage.ts b/src/common/hook/useSendMessage.ts index 65259c9f..4aaf69d5 100644 --- a/src/common/hook/useSendMessage.ts +++ b/src/common/hook/useSendMessage.ts @@ -14,7 +14,7 @@ interface Props { interface SendMessagesDTO { type: "text"; - content: string; + content: string | { path: string }; users: number[]; channels: number[]; } diff --git a/src/common/utils.tsx b/src/common/utils.tsx index e150f317..61c393b0 100644 --- a/src/common/utils.tsx +++ b/src/common/utils.tsx @@ -204,17 +204,18 @@ export const normalizeFileMessage = (data: MessagePayload) => { let res: null | { file_path?: string, content?: string, download?: string, thumbnail: string } = null; if (isFile) { if (!sending) { + const file_path = typeof content == "string" ? content : content.path; res = { - file_path: content, + file_path, content: `${BASE_URL}/resource/file?file_path=${encodeURIComponent( - content + file_path )}`, download: `${BASE_URL}/resource/file?file_path=${encodeURIComponent( - content + file_path )}&download=true`, thumbnail: (isPic && !isGif) ? `${BASE_URL}/resource/file?file_path=${encodeURIComponent( - content + file_path )}&thumbnail=true` : "" };