Skip to content

Commit

Permalink
81d352765fc7c632d81fb37381cc2f8be63d7fbb
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 27, 2024
1 parent 0d022e5 commit 1275922
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions esm/client/2_message_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
});
}
}
Expand Down
7 changes: 3 additions & 4 deletions script/client/2_message_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
});
}
}
Expand Down

0 comments on commit 1275922

Please sign in to comment.