From f9d3431401bcf351e1210400269dae87cf723984 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 15 May 2024 17:19:41 +0300 Subject: [PATCH] Add flag show_caption_above_media to relevant message content types. --- benchmark/bench_misc.cpp | 2 +- td/generate/scheme/td_api.tl | 9 ++++++--- td/telegram/MessageContent.cpp | 6 +++--- td/telegram/MessagesManager.cpp | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/benchmark/bench_misc.cpp b/benchmark/bench_misc.cpp index d6ddb6206..bfde3ab7f 100644 --- a/benchmark/bench_misc.cpp +++ b/benchmark/bench_misc.cpp @@ -117,7 +117,7 @@ BENCH(TlToStringMessage, "TL to_string message") { td::vector{10000, 20000, 30000, 50000, 70000, 90000, 120000, 150000, 180000, 220000})); } x->content_ = td::td_api::make_object( - std::move(photo), td::td_api::make_object(), false, false); + std::move(photo), td::td_api::make_object(), false, false, false); std::size_t res = 0; for (int i = 0; i < n; i++) { diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 29550b9f3..31f54d35f 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2999,9 +2999,10 @@ messageText text:formattedText web_page:webPage link_preview_options:linkPreview //@description An animation message (GIF-style). //@animation The animation description //@caption Animation caption +//@show_caption_above_media True, if caption must be shown above the animation; otherwise caption must be shown below the animation //@has_spoiler True, if the animation preview must be covered by a spoiler animation //@is_secret True, if the animation thumbnail must be blurred and the animation must be shown only while tapped -messageAnimation animation:animation caption:formattedText has_spoiler:Bool is_secret:Bool = MessageContent; +messageAnimation animation:animation caption:formattedText show_caption_above_media:Bool has_spoiler:Bool is_secret:Bool = MessageContent; //@description An audio message @audio The audio description @caption Audio caption messageAudio audio:audio caption:formattedText = MessageContent; @@ -3012,9 +3013,10 @@ messageDocument document:document caption:formattedText = MessageContent; //@description A photo message //@photo The photo //@caption Photo caption +//@show_caption_above_media True, if caption must be shown above the photo; otherwise caption must be shown below the photo //@has_spoiler True, if the photo preview must be covered by a spoiler animation //@is_secret True, if the photo must be blurred and must be shown only while tapped -messagePhoto photo:photo caption:formattedText has_spoiler:Bool is_secret:Bool = MessageContent; +messagePhoto photo:photo caption:formattedText show_caption_above_media:Bool has_spoiler:Bool is_secret:Bool = MessageContent; //@description A sticker message @sticker The sticker description @is_premium True, if premium animation of the sticker must be played messageSticker sticker:sticker is_premium:Bool = MessageContent; @@ -3022,9 +3024,10 @@ messageSticker sticker:sticker is_premium:Bool = MessageContent; //@description A video message //@video The video description //@caption Video caption +//@show_caption_above_media True, if caption must be shown above the video; otherwise caption must be shown below the video //@has_spoiler True, if the video preview must be covered by a spoiler animation //@is_secret True, if the video thumbnail must be blurred and the video must be shown only while tapped -messageVideo video:video caption:formattedText has_spoiler:Bool is_secret:Bool = MessageContent; +messageVideo video:video caption:formattedText show_caption_above_media:Bool has_spoiler:Bool is_secret:Bool = MessageContent; //@description A video note message @video_note The video note description @is_viewed True, if at least one of the recipients has viewed the video note @is_secret True, if the video note thumbnail must be blurred and the video note must be shown only while tapped messageVideoNote video_note:videoNote is_viewed:Bool is_secret:Bool = MessageContent; diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 7f59f0180..a08c31c58 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -6910,7 +6910,7 @@ tl_object_ptr get_message_content_object(const MessageCo const auto *m = static_cast(content); return make_tl_object( td->animations_manager_->get_animation_object(m->file_id), - get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp), m->has_spoiler, + get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp), invert_media, m->has_spoiler, is_content_secret); } case MessageContentType::Audio: { @@ -6958,7 +6958,7 @@ tl_object_ptr get_message_content_object(const MessageCo return make_tl_object(); } auto caption = get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp); - return make_tl_object(std::move(photo), std::move(caption), m->has_spoiler, + return make_tl_object(std::move(photo), std::move(caption), invert_media, m->has_spoiler, is_content_secret); } case MessageContentType::Sticker: { @@ -7010,7 +7010,7 @@ tl_object_ptr get_message_content_object(const MessageCo const auto *m = static_cast(content); return make_tl_object( td->videos_manager_->get_video_object(m->file_id), - get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp), m->has_spoiler, + get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp), invert_media, m->has_spoiler, is_content_secret); } case MessageContentType::VideoNote: { diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 4d7a86df0..83b0be1a5 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -25350,7 +25350,7 @@ void MessagesManager::edit_message_reply_markup(MessageFullId message_full_id, auto input_reply_markup = get_input_reply_markup(td_->user_manager_.get(), new_reply_markup); td_->create_handler(std::move(promise)) ->send(0, dialog_id, m->message_id, string(), vector>(), nullptr, - false, std::move(input_reply_markup), get_message_schedule_date(m)); + m->invert_media, std::move(input_reply_markup), get_message_schedule_date(m)); } void MessagesManager::edit_inline_message_text(const string &inline_message_id, @@ -25542,7 +25542,7 @@ void MessagesManager::edit_message_scheduling_state( if (schedule_date > 0) { td_->create_handler(std::move(promise)) ->send(0, dialog_id, m->message_id, string(), vector>(), nullptr, - false, nullptr, schedule_date); + m->invert_media, nullptr, schedule_date); } else { td_->create_handler(std::move(promise))->send(dialog_id, m->message_id); }