diff options
| author | levlam <levlam@telegram.org> | 2026-06-08 19:03:31 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2026-06-08 19:03:31 +0300 |
| commit | e6245bdf2a9b651d336eb1385999175ffd235b6e (patch) | |
| tree | eac7d0053868484fb5e922faf89898b0af5356b1 | |
| parent | 3271d2733205d01fb41007a40e5047a609554c85 (diff) | |
Add td_api::inputDocument.
| -rw-r--r-- | td/generate/scheme/td_api.tl | 17 | ||||
| -rw-r--r-- | td/telegram/MessageContent.cpp | 14 | ||||
| -rw-r--r-- | td/telegram/cli.cpp | 21 | ||||
| -rw-r--r-- | test/online.cpp | 3 | ||||
| -rw-r--r-- | test/tdclient.cpp | 13 |
5 files changed, 41 insertions, 27 deletions
diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index ae1974489..108cf4d47 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -5661,6 +5661,12 @@ inputAnimation animation:InputFile thumbnail:inputThumbnail added_sticker_file_i //@performer Performer of the audio; 0-64 characters, may be replaced by the server inputAudio audio:InputFile album_cover_thumbnail:inputThumbnail duration:int32 title:string performer:string = InputAudio; +//@description A document (general file) to be sent +//@document File to be sent +//@thumbnail Document thumbnail; pass null to skip thumbnail uploading +//@disable_content_type_detection Pass true to disable automatic file type detection and send the document as a file. Always true for files sent to secret chats +inputDocument document:InputFile thumbnail:inputThumbnail disable_content_type_detection:Bool = InputDocument; + //@class InputPaidMediaType @description Describes type of paid media to sent @@ -5743,11 +5749,8 @@ inputPollMediaAnimation animation:inputAnimation = InputPollMedia; //@description An audio @audio The audio to be sent inputPollMediaAudio audio:inputAudio = InputPollMedia; -//@description A document (general file) -//@document Document to be sent -//@thumbnail Document thumbnail; pass null to skip thumbnail uploading -//@disable_content_type_detection Pass true to disable automatic file type detection and send the document as a file -inputPollMediaDocument document:InputFile thumbnail:inputThumbnail disable_content_type_detection:Bool = InputPollMedia; +//@description A document (general file) @document The document to be sent +inputPollMediaDocument document:inputDocument = InputPollMedia; //@description A link @url URL of the link inputPollMediaLink url:string = InputPollMedia; @@ -5812,10 +5815,8 @@ inputMessageAudio audio:inputAudio caption:formattedText = InputMessageContent; //@description A document message (general file) //@document Document to be sent -//@thumbnail Document thumbnail; pass null to skip thumbnail uploading -//@disable_content_type_detection Pass true to disable automatic file type detection and send the document as a file. Always true for files sent to secret chats //@caption Document caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters -inputMessageDocument document:InputFile thumbnail:inputThumbnail disable_content_type_detection:Bool caption:formattedText = InputMessageContent; +inputMessageDocument document:inputDocument caption:formattedText = InputMessageContent; //@description A message with paid media; can be used only in channel chats with supergroupFullInfo.has_paid_media_allowed //@star_count The number of Telegram Stars that must be paid to see the media; 1-getOption("paid_media_message_star_count_max") diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index ac84aef2a..63c82c392 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -5093,10 +5093,14 @@ Result<InputMessageContent> get_input_message_content( } case td_api::inputMessageDocument::ID: { auto input_message = static_cast<td_api::inputMessageDocument *>(input_message_content.get()); - file_type = input_message->disable_content_type_detection_ ? FileType::DocumentAsFile : FileType::Document; - input_file = std::move(input_message->document_); + auto *document = input_message->document_.get(); + if (document == nullptr) { + return Status::Error(400, "Document must be non-empty"); + } + file_type = document->disable_content_type_detection_ ? FileType::DocumentAsFile : FileType::Document; + input_file = std::move(document->document_); allow_get_by_hash = true; - input_thumbnail = std::move(input_message->thumbnail_); + input_thumbnail = std::move(document->thumbnail_); break; } case td_api::inputMessagePhoto::ID: { @@ -5201,9 +5205,7 @@ Result<unique_ptr<MessageContent>> get_input_poll_media(DialogId dialog_id, } case td_api::inputPollMediaDocument::ID: { auto content = td_api::move_object_as<td_api::inputPollMediaDocument>(input_poll_media); - return td_api::make_object<td_api::inputMessageDocument>(std::move(content->document_), - std::move(content->thumbnail_), - content->disable_content_type_detection_, nullptr); + return td_api::make_object<td_api::inputMessageDocument>(std::move(content->document_), nullptr); } case td_api::inputPollMediaLocation::ID: { auto content = td_api::move_object_as<td_api::inputPollMediaLocation>(input_poll_media); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 09db5b331..c47662141 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -6426,8 +6426,9 @@ class CliClient final : public Actor { get_caption(), show_caption_above_media_, rand_bool() ? get_message_self_destruct_type() : nullptr, has_spoiler_ && rand_bool()); } else if (op == "smad") { - content = td_api::make_object<td_api::inputMessageDocument>(as_input_file(file), get_input_thumbnail(), true, - get_caption()); + content = td_api::make_object<td_api::inputMessageDocument>( + td_api::make_object<td_api::inputDocument>(as_input_file(file), get_input_thumbnail(), true), + get_caption()); } else if (op == "smav") { content = td_api::make_object<td_api::inputMessageVideo>( as_input_file(file), get_input_thumbnail(), get_input_cover(), start_timestamp_, @@ -6519,7 +6520,8 @@ class CliClient final : public Actor { string document; get_args(args, chat_id, message_id, document); auto input_document = td_api::make_object<td_api::inputMessageDocument>( - as_input_file(document), get_input_thumbnail(), false, get_caption()); + td_api::make_object<td_api::inputDocument>(as_input_file(document), get_input_thumbnail(), false), + get_caption()); if (!business_connection_id_.empty()) { send_request(td_api::make_object<td_api::editBusinessMessageMedia>(business_connection_id_, chat_id, message_id, nullptr, std::move(input_document))); @@ -6534,8 +6536,9 @@ class CliClient final : public Actor { get_args(args, shortcut_id, message_id, document); send_request(td_api::make_object<td_api::editQuickReplyMessage>( shortcut_id, message_id, - td_api::make_object<td_api::inputMessageDocument>(as_input_file(document), get_input_thumbnail(), false, - get_caption()))); + td_api::make_object<td_api::inputMessageDocument>( + td_api::make_object<td_api::inputDocument>(as_input_file(document), get_input_thumbnail(), false), + get_caption()))); } else if (op == "emp") { ChatId chat_id; MessageId message_id; @@ -6880,7 +6883,9 @@ class CliClient final : public Actor { string document; get_args(args, chat_id, document); send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>( - as_input_file(document), get_input_thumbnail(), op == "sdf", get_caption())); + td_api::make_object<td_api::inputDocument>(as_input_file(document), + get_input_thumbnail(), op == "sdf"), + get_caption())); } else if (op == "sdgu") { ChatId chat_id; string document_path; @@ -6889,7 +6894,9 @@ class CliClient final : public Actor { send_request(td_api::make_object<td_api::preliminaryUploadFile>( as_generated_file(document_path, document_conversion), nullptr, 1)); send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>( - as_generated_file(document_path, document_conversion), nullptr, false, get_caption())); + td_api::make_object<td_api::inputDocument>( + as_generated_file(document_path, document_conversion), nullptr, false), + get_caption())); } else if (op == "sg") { ChatId chat_id; UserId bot_user_id; diff --git a/test/online.cpp b/test/online.cpp index ff4e068be..29e81fc01 100644 --- a/test/online.cpp +++ b/test/online.cpp @@ -338,7 +338,8 @@ class UploadFile : public Task { send_query(td::make_tl_object<td::td_api::sendMessage>( chat_id_, nullptr, nullptr, nullptr, nullptr, td::make_tl_object<td::td_api::inputMessageDocument>( - td::make_tl_object<td::td_api::inputFileLocal>(content_path_), nullptr, true, + td::td_api::make_object<td::td_api::inputDocument>( + td::make_tl_object<td::td_api::inputFileLocal>(content_path_), nullptr, true), td::make_tl_object<td::td_api::formattedText>("tag", td::Auto()))), [this](td::Result<td::td_api::object_ptr<td::td_api::message>> res) { with_message(res.move_as_ok()); }); } diff --git a/test/tdclient.cpp b/test/tdclient.cpp index bdd497794..48314bb2f 100644 --- a/test/tdclient.cpp +++ b/test/tdclient.cpp @@ -497,16 +497,19 @@ class TestFileGenerated final : public TestClinetTask { send_query(td::make_tl_object<td::td_api::sendMessage>( chat_id_, nullptr, nullptr, nullptr, nullptr, td::make_tl_object<td::td_api::inputMessageDocument>( - td::make_tl_object<td::td_api::inputFileGenerated>(file_path, "square", 0), - td::make_tl_object<td::td_api::inputThumbnail>( - td::make_tl_object<td::td_api::inputFileGenerated>(file_path, "thumbnail", 0), 0, 0), - true, td::make_tl_object<td::td_api::formattedText>(tag_, td::Auto()))), + td::td_api::make_object<td::td_api::inputDocument>( + td::make_tl_object<td::td_api::inputFileGenerated>(file_path, "square", 0), + td::make_tl_object<td::td_api::inputThumbnail>( + td::make_tl_object<td::td_api::inputFileGenerated>(file_path, "thumbnail", 0), 0, 0), + true), + td::make_tl_object<td::td_api::formattedText>(tag_, td::Auto()))), [](auto res) { check_td_error(res); }); send_query(td::make_tl_object<td::td_api::sendMessage>( chat_id_, nullptr, nullptr, nullptr, nullptr, td::make_tl_object<td::td_api::inputMessageDocument>( - td::make_tl_object<td::td_api::inputFileGenerated>(file_path, "square", 0), nullptr, true, + td::td_api::make_object<td::td_api::inputDocument>( + td::make_tl_object<td::td_api::inputFileGenerated>(file_path, "square", 0), nullptr, true), td::make_tl_object<td::td_api::formattedText>(tag_, td::Auto()))), [](auto res) { check_td_error(res); }); } |
