Remove unused get_formatted_text parameters.

This commit is contained in:
levlam 2024-04-23 20:04:38 +03:00
parent 8e2713ca93
commit e08cf00efb
11 changed files with 24 additions and 34 deletions

View File

@ -409,9 +409,8 @@ DraftMessage::DraftMessage(Td *td, telegram_api::object_ptr<telegram_api::draftM
CHECK(draft_message != nullptr);
date_ = draft_message->date_;
message_input_reply_to_ = MessageInputReplyTo(td, std::move(draft_message->reply_to_));
auto draft_text =
get_formatted_text(td->user_manager_.get(), std::move(draft_message->message_),
std::move(draft_message->entities_), true, true, true, true, true, "DraftMessage");
auto draft_text = get_formatted_text(td->user_manager_.get(), std::move(draft_message->message_),
std::move(draft_message->entities_), true, true, true, "DraftMessage");
string web_page_url;
bool force_small_media = false;
bool force_large_media = false;

View File

@ -849,7 +849,7 @@ class GetDeepLinkInfoQuery final : public Td::ResultHandler {
case telegram_api::help_deepLinkInfo::ID: {
auto info = telegram_api::move_object_as<telegram_api::help_deepLinkInfo>(result);
auto text = get_formatted_text(nullptr, std::move(info->message_), std::move(info->entities_), true, true, true,
true, true, "GetDeepLinkInfoQuery");
"GetDeepLinkInfoQuery");
return promise_.set_value(
td_api::make_object<td_api::deepLinkInfo>(get_formatted_text_object(text, true, -1), info->update_app_));
}

View File

@ -2472,8 +2472,7 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id,
case telegram_api::botInlineMessageText::ID: {
auto inline_message = move_tl_object_as<telegram_api::botInlineMessageText>(bot_inline_message);
auto text = get_formatted_text(td->user_manager_.get(), std::move(inline_message->message_),
std::move(inline_message->entities_), false, true, true, false, false,
"botInlineMessageText");
std::move(inline_message->entities_), false, false, false, "botInlineMessageText");
result.disable_web_page_preview = inline_message->no_webpage_;
result.invert_media = inline_message->invert_media_;
WebPageId web_page_id;
@ -2492,8 +2491,8 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id,
web_page_url = std::move(inline_message->url_);
}
auto text = get_formatted_text(td->user_manager_.get(), std::move(inline_message->message_),
std::move(inline_message->entities_), !web_page_url.empty(), true, true, false,
false, "botInlineMessageMediaWebPage");
std::move(inline_message->entities_), !web_page_url.empty(), false, false,
"botInlineMessageMediaWebPage");
auto web_page_id =
td->web_pages_manager_->get_web_page_by_url(web_page_url.empty() ? get_first_url(text).str() : web_page_url);
result.message_content = td::make_unique<MessageText>(

View File

@ -3951,29 +3951,26 @@ telegram_api::object_ptr<telegram_api::textWithEntities> get_input_text_with_ent
FormattedText get_formatted_text(const UserManager *user_manager, string &&text,
vector<telegram_api::object_ptr<telegram_api::MessageEntity>> &&server_entities,
bool allow_empty, bool skip_new_entities, bool skip_bot_commands,
bool skip_media_timestamps, bool skip_trim, const char *source) {
bool allow_empty, bool skip_media_timestamps, bool skip_trim, const char *source) {
auto entities = get_message_entities(user_manager, std::move(server_entities), source);
auto status = fix_formatted_text(text, entities, allow_empty, skip_new_entities, skip_bot_commands,
skip_media_timestamps, skip_trim);
auto status = fix_formatted_text(text, entities, allow_empty, true, true, skip_media_timestamps, skip_trim);
if (status.is_error()) {
LOG(ERROR) << "Receive error " << status << " from " << source << " while parsing " << text;
if (!clean_input_string(text)) {
text.clear();
}
entities = find_entities(text, skip_bot_commands, skip_media_timestamps);
entities = find_entities(text, true, skip_media_timestamps);
}
return {std::move(text), std::move(entities)};
}
FormattedText get_formatted_text(const UserManager *user_manager,
telegram_api::object_ptr<telegram_api::textWithEntities> text_with_entities,
bool allow_empty, bool skip_new_entities, bool skip_bot_commands,
bool skip_media_timestamps, bool skip_trim, const char *source) {
bool allow_empty, bool skip_media_timestamps, bool skip_trim, const char *source) {
CHECK(text_with_entities != nullptr);
return get_formatted_text(user_manager, std::move(text_with_entities->text_),
std::move(text_with_entities->entities_), allow_empty, skip_new_entities, skip_bot_commands,
skip_media_timestamps, skip_trim, source);
std::move(text_with_entities->entities_), allow_empty, skip_media_timestamps, skip_trim,
source);
}
// like clean_input_string but also fixes entities

View File

@ -221,13 +221,11 @@ telegram_api::object_ptr<telegram_api::textWithEntities> get_input_text_with_ent
FormattedText get_formatted_text(const UserManager *user_manager, string &&text,
vector<telegram_api::object_ptr<telegram_api::MessageEntity>> &&server_entities,
bool allow_empty, bool skip_new_entities, bool skip_bot_commands,
bool skip_media_timestamps, bool skip_trim, const char *source);
bool allow_empty, bool skip_media_timestamps, bool skip_trim, const char *source);
FormattedText get_formatted_text(const UserManager *user_manager,
telegram_api::object_ptr<telegram_api::textWithEntities> text_with_entities,
bool allow_empty, bool skip_new_entities, bool skip_bot_commands,
bool skip_media_timestamps, bool skip_trim, const char *source);
bool allow_empty, bool skip_media_timestamps, bool skip_trim, const char *source);
// like clean_input_string but also validates entities
Status fix_formatted_text(string &text, vector<MessageEntity> &entities, bool allow_empty, bool skip_new_entities,

View File

@ -58,8 +58,7 @@ MessageInputReplyTo::MessageInputReplyTo(Td *td,
if (!reply_to->quote_text_.empty()) {
quote_ = get_formatted_text(td->user_manager_.get(), std::move(reply_to->quote_text_),
std::move(reply_to->quote_entities_), true, true, true, true, false,
"inputReplyToMessage");
std::move(reply_to->quote_entities_), true, true, false, "inputReplyToMessage");
remove_unallowed_quote_entities(quote_);
quote_position_ = max(0, reply_to->quote_offset_);
}

View File

@ -25480,9 +25480,9 @@ void MessagesManager::edit_inline_message_caption(const string &inline_message_i
Promise<Unit> &&promise) {
CHECK(td_->auth_manager_->is_bot());
TRY_RESULT_PROMISE(
promise, caption,
get_formatted_text(td_, DialogId(), std::move(input_caption), td_->auth_manager_->is_bot(), true, false, false));
TRY_RESULT_PROMISE(promise, caption,
get_formatted_text(td_, td_->dialog_manager_->get_my_dialog_id(), std::move(input_caption),
td_->auth_manager_->is_bot(), true, false, false));
TRY_RESULT_PROMISE(promise, new_reply_markup,
get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false, true));

View File

@ -1812,9 +1812,8 @@ PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll
}
}
auto explanation =
get_formatted_text(td_->user_manager_.get(), std::move(poll_results->solution_),
std::move(poll_results->solution_entities_), true, true, true, true, false, source);
auto explanation = get_formatted_text(td_->user_manager_.get(), std::move(poll_results->solution_),
std::move(poll_results->solution_entities_), true, true, false, source);
if (poll->is_quiz_) {
if (poll->correct_option_id_ != correct_option_id) {
if (correct_option_id == -1 && poll->correct_option_id_ != -1) {

View File

@ -118,8 +118,7 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
if ((!origin_.is_empty() || message_id_ != MessageId()) && !reply_header->quote_text_.empty()) {
is_quote_manual_ = reply_header->quote_;
quote_ = get_formatted_text(td->user_manager_.get(), std::move(reply_header->quote_text_),
std::move(reply_header->quote_entities_), true, true, true, true, false,
"RepliedMessageInfo");
std::move(reply_header->quote_entities_), true, true, false, "RepliedMessageInfo");
remove_unallowed_quote_entities(quote_);
quote_position_ = max(0, reply_header->quote_offset_);
}

View File

@ -95,8 +95,8 @@ TermsOfService::TermsOfService(telegram_api::object_ptr<telegram_api::help_terms
}
id_ = std::move(terms->id_->data_);
text_ = get_formatted_text(nullptr, std::move(terms->text_), std::move(terms->entities_), true, true, true, true,
false, "TermsOfService");
text_ = get_formatted_text(nullptr, std::move(terms->text_), std::move(terms->entities_), true, true, false,
"TermsOfService");
if (text_.text.empty()) {
id_.clear();
}

View File

@ -119,7 +119,7 @@ void TranslationManager::on_get_translated_texts(vector<telegram_api::object_ptr
if (texts.size() != 1u) {
return promise.set_error(Status::Error(500, "Receive invalid number of results"));
}
auto formatted_text = get_formatted_text(td_->user_manager_.get(), std::move(texts[0]), true, true, skip_bot_commands,
auto formatted_text = get_formatted_text(td_->user_manager_.get(), std::move(texts[0]), true,
max_media_timestamp == -1, true, "on_get_translated_texts");
promise.set_value(get_formatted_text_object(formatted_text, skip_bot_commands, max_media_timestamp));
}