From cc08225d30276a0d2b8025693d52bc97008dd8c3 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 17 Oct 2023 00:37:44 +0300 Subject: [PATCH] Always use the first URL as web_page_url in secret chats. --- td/telegram/InputMessageText.cpp | 3 +++ td/telegram/MessageContent.cpp | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/td/telegram/InputMessageText.cpp b/td/telegram/InputMessageText.cpp index cb8264bcf..7c1803c07 100644 --- a/td/telegram/InputMessageText.cpp +++ b/td/telegram/InputMessageText.cpp @@ -57,6 +57,9 @@ Result process_input_message_text(const Td *td, DialogId dialo force_large_media = false; } } + if (!disable_web_page_preview && web_page_url.empty() && dialog_id.get_type() == DialogType::SecretChat) { + web_page_url = get_first_url(text); + } return InputMessageText{std::move(text), std::move(web_page_url), disable_web_page_preview, force_small_media, force_large_media, input_message_text->clear_draft_}; } diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 0dfdb1187..d654695bd 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -2719,12 +2719,10 @@ SecretInputMedia get_secret_input_media(const MessageContent *content, Td *td, CHECK(input_file == nullptr); CHECK(thumbnail.empty()); const auto *m = static_cast(content); - auto web_page_url = - !m->web_page_url.empty() ? m->web_page_url : td->web_pages_manager_->get_web_page_url(m->web_page_id); - if (web_page_url.empty()) { + if (m->web_page_url.empty()) { return SecretInputMedia{}; } - return SecretInputMedia{nullptr, make_tl_object(web_page_url)}; + return SecretInputMedia{nullptr, make_tl_object(m->web_page_url)}; } case MessageContentType::Venue: { const auto *m = static_cast(content);