From 1275922407693e7938f89c708cb8a6015606947b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:09:56 +0000 Subject: [PATCH] 81d352765fc7c632d81fb37381cc2f8be63d7fbb --- esm/client/2_message_manager.js | 7 +++---- script/client/2_message_manager.js | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/esm/client/2_message_manager.js b/esm/client/2_message_manager.js index f5a365f..2e40fa3 100644 --- a/esm/client/2_message_manager.js +++ b/esm/client/2_message_manager.js @@ -19,6 +19,7 @@ import { messageSearchFilterToTlObject } from "../types/0_message_search_filter. import { parseHtml } from "./0_html.js"; import { parseMarkdown } from "./0_markdown.js"; import { getFileContents, isHttpUrl } from "./0_utilities.js"; +const FALLBACK_MIME_TYPE = "application/octet-stream"; const STICKER_MIME_TYPES = ["image/webp", "video/webp", "application/x-tgsticker"]; export class MessageManager { constructor(c) { @@ -1066,13 +1067,10 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap( else { const [contents, fileName_] = await getFileContents(document); const fileName = params?.fileName ?? fileName_; - let mimeType = params?.mimeType ?? contentType(fileName.split(".").slice(-1)[0]) ?? "application/octet-stream"; + const mimeType = params?.mimeType ?? contentType(fileName.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE; if (expectedMimeTypes && !expectedMimeTypes.includes(mimeType)) { UNREACHABLE(); } - if (STICKER_MIME_TYPES.includes(mimeType) && !expectedMimeTypes) { - mimeType = "application/octet-stream"; - } const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal }); let thumb = undefined; if (params?.thumbnail) { @@ -1085,6 +1083,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap( spoiler, attributes: [new types.DocumentAttributeFilename({ file_name: fileName }), ...otherAttribs], mime_type: mimeType, + force_file: fileType == FileType.Document ? true : undefined, }); } } diff --git a/script/client/2_message_manager.js b/script/client/2_message_manager.js index 446dc6d..76488e5 100644 --- a/script/client/2_message_manager.js +++ b/script/client/2_message_manager.js @@ -22,6 +22,7 @@ const _0_message_search_filter_js_1 = require("../types/0_message_search_filter. const _0_html_js_1 = require("./0_html.js"); const _0_markdown_js_1 = require("./0_markdown.js"); const _0_utilities_js_1 = require("./0_utilities.js"); +const FALLBACK_MIME_TYPE = "application/octet-stream"; const STICKER_MIME_TYPES = ["image/webp", "video/webp", "application/x-tgsticker"]; class MessageManager { constructor(c) { @@ -1070,13 +1071,10 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap( else { const [contents, fileName_] = await (0, _0_utilities_js_1.getFileContents)(document); const fileName = params?.fileName ?? fileName_; - let mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(fileName.split(".").slice(-1)[0]) ?? "application/octet-stream"; + const mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(fileName.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE; if (expectedMimeTypes && !expectedMimeTypes.includes(mimeType)) { (0, _1_utilities_js_1.UNREACHABLE)(); } - if (STICKER_MIME_TYPES.includes(mimeType) && !expectedMimeTypes) { - mimeType = "application/octet-stream"; - } const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal }); let thumb = undefined; if (params?.thumbnail) { @@ -1089,6 +1087,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap( spoiler, attributes: [new _2_tl_js_1.types.DocumentAttributeFilename({ file_name: fileName }), ...otherAttribs], mime_type: mimeType, + force_file: fileType == _3_types_js_2.FileType.Document ? true : undefined, }); } }