From 294c075867dfaf90af846cc3296fed2aca90dcbf Mon Sep 17 00:00:00 2001 From: abdou6666 Date: Thu, 30 Jan 2025 12:45:54 +0100 Subject: [PATCH 1/4] fix: updated attachments mime types --- frontend/src/utils/attachment.ts | 38 +++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/frontend/src/utils/attachment.ts b/frontend/src/utils/attachment.ts index 93254491..b68cfd59 100644 --- a/frontend/src/utils/attachment.ts +++ b/frontend/src/utils/attachment.ts @@ -6,24 +6,46 @@ * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ - import { IAttachment } from "@/types/attachment.types"; import { FileType, TAttachmentForeignKey } from "@/types/message.types"; import { buildURL } from "./URL"; export const MIME_TYPES = { - images: ["image/jpeg", "image/png", "image/gif", "image/webp"], - videos: ["video/mp4", "video/webm", "video/ogg"], - audios: ["audio/mpeg", "audio/ogg", "audio/wav"], + images: ["image/jpeg", "image/png", "image/webp", "image/bmp"], + videos: [ + "video/mp4", + "video/webm", + "video/ogg", + "video/quicktime", // common in apple devices + "video/x-msvideo", // AVI + "video/x-matroska", // MKV + ], + audios: [ + "audio/mpeg", // MP3 + "audio/mp3", // Explicit MP3 type + "audio/ogg", + "audio/wav", + "audio/aac", // common in apple devices + "audio/x-wav", + ], documents: [ "application/pdf", - "application/msword", + "application/msword", // older ms Word format + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", // newer ms word format "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - "application/vnd.ms-excel", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.ms-excel", // older excel format + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // newer excel format "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "text/plain", + "application/rtf", + "application/epub", // do we want to support epub? + "application/x-7z-compressed", // do we want to support 7z? + "application/zip", // do we want to support zip? + "application/x-rar-compressed", // do we want to support winrar? + "application/json", + "text/csv", ], }; @@ -68,4 +90,4 @@ export function extractFilenameFromUrl(url: string) { // If the URL is invalid, return the input as-is return url; } -} \ No newline at end of file +} From 0f5a67c2cecd26387607d2111181878582fa5655 Mon Sep 17 00:00:00 2001 From: abdou6666 Date: Thu, 30 Jan 2025 12:50:15 +0100 Subject: [PATCH 2/4] fix: avatar/nlu import to use accepted mime type props --- frontend/src/app-components/inputs/FileInput.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app-components/inputs/FileInput.tsx b/frontend/src/app-components/inputs/FileInput.tsx index f6d52d58..c6da510b 100644 --- a/frontend/src/app-components/inputs/FileInput.tsx +++ b/frontend/src/app-components/inputs/FileInput.tsx @@ -1,11 +1,12 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ + import UploadIcon from "@mui/icons-material/Upload"; import { Button, CircularProgress } from "@mui/material"; import { ChangeEvent, forwardRef } from "react"; @@ -71,6 +72,7 @@ const FileUploadButton = forwardRef( value="" // to trigger an automatic reset to allow the same file to be selected multiple times sx={{ display: "none" }} onChange={handleImportChange} + inputProps={{ accept }} /> ); From b534e47edd1653e08734b05005be9b9fa24ff7f3 Mon Sep 17 00:00:00 2001 From: abdou6666 Date: Thu, 30 Jan 2025 12:51:42 +0100 Subject: [PATCH 3/4] fix: widget FileButton to use mime types --- widget/src/components/buttons/FileButton.tsx | 11 +++++- widget/src/utils/attachment.ts | 41 +++++++++++++++++++- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/widget/src/components/buttons/FileButton.tsx b/widget/src/components/buttons/FileButton.tsx index 22aa0117..f04e79ad 100644 --- a/widget/src/components/buttons/FileButton.tsx +++ b/widget/src/components/buttons/FileButton.tsx @@ -1,14 +1,16 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ -import React, { ChangeEvent } from "react"; + +import React, { ChangeEvent, useMemo } from "react"; import { useChat } from "../../providers/ChatProvider"; +import { MIME_TYPES } from "../../utils/attachment"; import FileInputIcon from "../icons/FileInputIcon"; import "./FileButton.scss"; @@ -23,12 +25,17 @@ const FileButton: React.FC = () => { setFile && setFile(e.target.files[0]); } }; + const acceptedMimeTypes = useMemo( + () => Object.values(MIME_TYPES).flat().join(""), + [], + ); return (