Better message entities debug.

GitOrigin-RevId: 05fea435da021773ca6fbb76e81680e4913cde51
This commit is contained in:
levlam 2019-12-23 19:01:47 +03:00
parent 8da2d89884
commit 64f73bebff
2 changed files with 8 additions and 3 deletions

View File

@ -2670,11 +2670,14 @@ FormattedText get_message_text(const ContactsManager *contacts_manager, string m
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities, vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
bool skip_new_entities, int32 send_date, const char *source) { bool skip_new_entities, int32 send_date, const char *source) {
auto entities = get_message_entities(contacts_manager, std::move(server_entities), source); auto entities = get_message_entities(contacts_manager, std::move(server_entities), source);
auto debug_message_text = message_text;
auto debug_entities = entities;
auto status = fix_formatted_text(message_text, entities, true, skip_new_entities, true, false); auto status = fix_formatted_text(message_text, entities, true, skip_new_entities, true, false);
if (status.is_error()) { if (status.is_error()) {
if (send_date == 0 || send_date > 1497000000) { // approximate fix date if (send_date == 0 || send_date > 1497000000) { // approximate fix date
LOG(ERROR) << "Receive error " << status << " while parsing message from " << source << " with content \"" LOG(ERROR) << "Receive error " << status << " while parsing message text from " << source << " with content \""
<< message_text << "\" sent at " << send_date << " with entities " << format::as_array(entities); << debug_message_text << "\" -> \"" << message_text << "\" sent at " << send_date << " with entities "
<< format::as_array(debug_entities) << " -> " << format::as_array(entities);
} }
if (!clean_input_string(message_text)) { if (!clean_input_string(message_text)) {
message_text.clear(); message_text.clear();

View File

@ -10954,11 +10954,13 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
if (is_scheduled) { if (is_scheduled) {
is_content_read = false; is_content_read = false;
} }
auto new_source = PSTRING() << FullMessageId(message_info.dialog_id, message_info.message_id) << " from "
<< source;
message_info.content = get_message_content( message_info.content = get_message_content(
td_, td_,
get_message_text(td_->contacts_manager_.get(), std::move(message->message_), std::move(message->entities_), get_message_text(td_->contacts_manager_.get(), std::move(message->message_), std::move(message->entities_),
true, message_info.forward_header ? message_info.forward_header->date_ : message_info.date, true, message_info.forward_header ? message_info.forward_header->date_ : message_info.date,
"parse_telegram_api_message"), new_source.c_str()),
std::move(message->media_), message_info.dialog_id, is_content_read, message_info.via_bot_user_id, std::move(message->media_), message_info.dialog_id, is_content_read, message_info.via_bot_user_id,
&message_info.ttl); &message_info.ttl);
message_info.reply_markup = message_info.reply_markup =