Allow empty text witn non-empty link preview.
This commit is contained in:
parent
af2f07a1d7
commit
72cb3665b4
@ -30,8 +30,6 @@ Result<InputMessageText> process_input_message_text(const Td *td, DialogId dialo
|
||||
CHECK(input_message_content != nullptr);
|
||||
CHECK(input_message_content->get_id() == td_api::inputMessageText::ID);
|
||||
auto input_message_text = static_cast<td_api::inputMessageText *>(input_message_content.get());
|
||||
TRY_RESULT(text, get_formatted_text(td, dialog_id, std::move(input_message_text->text_), is_bot, for_draft, for_draft,
|
||||
for_draft));
|
||||
string web_page_url;
|
||||
bool disable_web_page_preview = false;
|
||||
bool force_small_media = false;
|
||||
@ -57,6 +55,8 @@ Result<InputMessageText> process_input_message_text(const Td *td, DialogId dialo
|
||||
force_large_media = false;
|
||||
}
|
||||
}
|
||||
TRY_RESULT(text, get_formatted_text(td, dialog_id, std::move(input_message_text->text_), is_bot,
|
||||
for_draft || !web_page_url.empty(), for_draft, for_draft));
|
||||
if (!disable_web_page_preview && web_page_url.empty() && dialog_id.get_type() == DialogType::SecretChat) {
|
||||
web_page_url = get_first_url(text);
|
||||
}
|
||||
|
@ -2084,19 +2084,20 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id,
|
||||
}
|
||||
case telegram_api::botInlineMessageMediaWebPage::ID: {
|
||||
auto inline_message = move_tl_object_as<telegram_api::botInlineMessageMediaWebPage>(bot_inline_message);
|
||||
string web_page_url;
|
||||
if (inline_message->manual_) {
|
||||
web_page_url = std::move(inline_message->url_);
|
||||
}
|
||||
auto entities = get_message_entities(td->contacts_manager_.get(), std::move(inline_message->entities_),
|
||||
"botInlineMessageMediaWebPage");
|
||||
auto status = fix_formatted_text(inline_message->message_, entities, true, true, true, false, false);
|
||||
auto status =
|
||||
fix_formatted_text(inline_message->message_, entities, !web_page_url.empty(), true, true, false, false);
|
||||
if (status.is_error()) {
|
||||
LOG(ERROR) << "Receive error " << status << " while parsing botInlineMessageMediaWebPage "
|
||||
<< inline_message->message_;
|
||||
break;
|
||||
}
|
||||
|
||||
string web_page_url;
|
||||
if (inline_message->manual_) {
|
||||
web_page_url = std::move(inline_message->url_);
|
||||
}
|
||||
FormattedText text{std::move(inline_message->message_), std::move(entities)};
|
||||
WebPageId web_page_id =
|
||||
td->web_pages_manager_->get_web_page_by_url(web_page_url.empty() ? get_first_url(text) : web_page_url);
|
||||
|
@ -877,8 +877,9 @@ void WebPagesManager::on_get_web_page_preview_success(const string &first_url, W
|
||||
|
||||
void WebPagesManager::get_web_page_preview(td_api::object_ptr<td_api::formattedText> &&text,
|
||||
Promise<td_api::object_ptr<td_api::webPage>> &&promise) {
|
||||
TRY_RESULT_PROMISE(promise, formatted_text,
|
||||
get_formatted_text(td_, DialogId(), std::move(text), false, true, true, true));
|
||||
TRY_RESULT_PROMISE(
|
||||
promise, formatted_text,
|
||||
get_formatted_text(td_, DialogId(), std::move(text), td_->auth_manager_->is_bot(), true, true, true));
|
||||
|
||||
auto first_url = get_first_url(formatted_text);
|
||||
if (first_url.empty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user