Add additional parameters to get_formatted_text.
This commit is contained in:
parent
61fb071b25
commit
8b61255387
@ -30,7 +30,8 @@ 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));
|
||||
TRY_RESULT(text, get_formatted_text(td, dialog_id, std::move(input_message_text->text_), is_bot, for_draft, for_draft,
|
||||
for_draft));
|
||||
return InputMessageText{std::move(text), input_message_text->disable_web_page_preview_,
|
||||
input_message_text->clear_draft_};
|
||||
}
|
||||
|
@ -4305,9 +4305,9 @@ Result<FormattedText> process_input_caption(const ContactsManager *contacts_mana
|
||||
|
||||
Result<FormattedText> get_formatted_text(const Td *td, DialogId dialog_id,
|
||||
td_api::object_ptr<td_api::formattedText> &&text, bool is_bot,
|
||||
bool for_draft) {
|
||||
bool allow_empty, bool skip_media_timestamps, bool for_draft) {
|
||||
if (text == nullptr) {
|
||||
if (for_draft) {
|
||||
if (allow_empty) {
|
||||
return FormattedText();
|
||||
}
|
||||
|
||||
@ -4317,14 +4317,14 @@ Result<FormattedText> get_formatted_text(const Td *td, DialogId dialog_id,
|
||||
TRY_RESULT(entities, get_message_entities(td->contacts_manager_.get(), std::move(text->entities_)));
|
||||
auto need_skip_bot_commands = need_always_skip_bot_commands(td->contacts_manager_.get(), dialog_id, is_bot);
|
||||
bool parse_markdown = G()->shared_config().get_option_boolean("always_parse_markdown");
|
||||
TRY_STATUS(fix_formatted_text(text->text_, entities, for_draft, parse_markdown, need_skip_bot_commands,
|
||||
is_bot || for_draft || parse_markdown, for_draft));
|
||||
TRY_STATUS(fix_formatted_text(text->text_, entities, allow_empty, parse_markdown, need_skip_bot_commands,
|
||||
is_bot || skip_media_timestamps || parse_markdown, for_draft));
|
||||
|
||||
FormattedText result{std::move(text->text_), std::move(entities)};
|
||||
if (parse_markdown) {
|
||||
result = parse_markdown_v3(std::move(result));
|
||||
fix_formatted_text(result.text, result.entities, for_draft, false, need_skip_bot_commands, is_bot || for_draft,
|
||||
for_draft)
|
||||
fix_formatted_text(result.text, result.entities, allow_empty, false, need_skip_bot_commands,
|
||||
is_bot || skip_media_timestamps, for_draft)
|
||||
.ensure();
|
||||
}
|
||||
remove_unallowed_entities(td, result, dialog_id);
|
||||
|
@ -216,7 +216,8 @@ Result<FormattedText> process_input_caption(const ContactsManager *contacts_mana
|
||||
tl_object_ptr<td_api::formattedText> &&caption, bool is_bot);
|
||||
|
||||
Result<FormattedText> get_formatted_text(const Td *td, DialogId dialog_id,
|
||||
td_api::object_ptr<td_api::formattedText> &&text, bool is_bot, bool for_draft);
|
||||
td_api::object_ptr<td_api::formattedText> &&text, bool is_bot,
|
||||
bool allow_empty, bool skip_media_timestamps, bool for_draft);
|
||||
|
||||
void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText *text);
|
||||
|
||||
|
@ -796,7 +796,7 @@ void WebPagesManager::on_get_web_page_preview_fail(int64 request_id, const strin
|
||||
}
|
||||
|
||||
int64 WebPagesManager::get_web_page_preview(td_api::object_ptr<td_api::formattedText> &&text, Promise<Unit> &&promise) {
|
||||
auto r_formatted_text = get_formatted_text(td_, DialogId(), std::move(text), false, true);
|
||||
auto r_formatted_text = get_formatted_text(td_, DialogId(), std::move(text), false, true, true, true);
|
||||
if (r_formatted_text.is_error()) {
|
||||
promise.set_error(r_formatted_text.move_as_error());
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user