fix: download url

This commit is contained in:
Tristan Yang
2023-03-31 08:24:38 +08:00
parent 0d19b7adec
commit 340b98d799
3 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -14,7 +14,7 @@ interface Props {
interface SendMessagesDTO {
type: "text";
content: string;
content: string | { path: string };
users: number[];
channels: number[];
}
+5 -4
View File
@@ -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`
: ""
};