Silence warning about wrong message entities for messages from albums.

GitOrigin-RevId: 13a60e258ab6aae8c80d5ea4cd8bb7037f56985c
This commit is contained in:
levlam 2020-01-29 02:05:12 +03:00
parent 0dcbe4973a
commit 8539d43951
5 changed files with 12 additions and 12 deletions

View File

@ -1330,9 +1330,9 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id,
} }
case telegram_api::botInlineMessageMediaAuto::ID: { case telegram_api::botInlineMessageMediaAuto::ID: {
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message); auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
auto caption = auto caption = get_message_text(td->contacts_manager_.get(), input_message_media_auto->message_,
get_message_text(td->contacts_manager_.get(), input_message_media_auto->message_, std::move(input_message_media_auto->entities_), true, 0, false,
std::move(input_message_media_auto->entities_), true, 0, "register_inline_message_content"); "register_inline_message_content");
if (allowed_media_content_id == td_api::inputMessageAnimation::ID) { if (allowed_media_content_id == td_api::inputMessageAnimation::ID) {
result.message_content = make_unique<MessageAnimation>(file_id, std::move(caption)); result.message_content = make_unique<MessageAnimation>(file_id, std::move(caption));
} else if (allowed_media_content_id == td_api::inputMessageAudio::ID) { } else if (allowed_media_content_id == td_api::inputMessageAudio::ID) {

View File

@ -2679,13 +2679,13 @@ Status fix_formatted_text(string &text, vector<MessageEntity> &entities, bool al
FormattedText get_message_text(const ContactsManager *contacts_manager, string message_text, FormattedText get_message_text(const ContactsManager *contacts_manager, string message_text,
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, bool from_album, 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_message_text = message_text;
auto debug_entities = entities; 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 > 1579219200) { // approximate fix date if (!from_album && (send_date == 0 || send_date > 1579219200)) { // approximate fix date
LOG(ERROR) << "Receive error " << status << " while parsing message text from " << source << " with content \"" LOG(ERROR) << "Receive error " << status << " while parsing message text from " << source << " with content \""
<< debug_message_text << "\" -> \"" << message_text << "\" sent at " << send_date << " with entities " << debug_message_text << "\" -> \"" << message_text << "\" sent at " << send_date << " with entities "
<< format::as_array(debug_entities) << " -> " << format::as_array(entities); << format::as_array(debug_entities) << " -> " << format::as_array(entities);

View File

@ -169,7 +169,7 @@ Status fix_formatted_text(string &text, vector<MessageEntity> &entities, bool al
FormattedText get_message_text(const ContactsManager *contacts_manager, string message_text, FormattedText get_message_text(const ContactsManager *contacts_manager, string message_text,
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, bool from_album, const char *source);
td_api::object_ptr<td_api::formattedText> extract_input_caption( td_api::object_ptr<td_api::formattedText> extract_input_caption(
tl_object_ptr<td_api::InputMessageContent> &input_message_content); tl_object_ptr<td_api::InputMessageContent> &input_message_content);

View File

@ -26,6 +26,7 @@
#include "td/telegram/logevent/LogEvent.h" #include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/logevent/LogEventHelper.h" #include "td/telegram/logevent/LogEventHelper.h"
#include "td/telegram/MessageContent.h" #include "td/telegram/MessageContent.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/MessageEntity.hpp" #include "td/telegram/MessageEntity.hpp"
#include "td/telegram/MessagesDb.h" #include "td/telegram/MessagesDb.h"
#include "td/telegram/misc.h" #include "td/telegram/misc.h"
@ -5444,7 +5445,7 @@ void MessagesManager::on_update_service_notification(tl_object_ptr<telegram_api:
auto date = has_date ? update->inbox_date_ : G()->unix_time(); auto date = has_date ? update->inbox_date_ : G()->unix_time();
auto message_text = auto message_text =
get_message_text(td_->contacts_manager_.get(), std::move(update->message_), std::move(update->entities_), get_message_text(td_->contacts_manager_.get(), std::move(update->message_), std::move(update->entities_),
skip_new_entities, date, "on_update_service_notification"); skip_new_entities, date, false, "on_update_service_notification");
auto content = get_message_content( auto content = get_message_content(
td_, std::move(message_text), std::move(update->media_), td_, std::move(message_text), std::move(update->media_),
td_->auth_manager_->is_bot() ? DialogId() : get_service_notifications_dialog()->dialog_id, false, UserId(), &ttl); td_->auth_manager_->is_bot() ? DialogId() : get_service_notifications_dialog()->dialog_id, false, UserId(), &ttl);
@ -11074,7 +11075,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
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,
new_source.c_str()), message_info.media_album_id != 0, 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 =
@ -11860,9 +11861,9 @@ void MessagesManager::on_update_sent_text_message(int64 random_id,
const FormattedText *old_message_text = get_message_content_text(m->content.get()); const FormattedText *old_message_text = get_message_content_text(m->content.get());
CHECK(old_message_text != nullptr); CHECK(old_message_text != nullptr);
FormattedText new_message_text = FormattedText new_message_text = get_message_text(
get_message_text(td_->contacts_manager_.get(), old_message_text->text, std::move(entities), true, td_->contacts_manager_.get(), old_message_text->text, std::move(entities), true,
m->forward_info ? m->forward_info->date : m->date, "on_update_sent_text_message"); m->forward_info ? m->forward_info->date : m->date, m->media_album_id != 0, "on_update_sent_text_message");
auto new_content = get_message_content(td_, std::move(new_message_text), std::move(message_media), dialog_id, auto new_content = get_message_content(td_, std::move(new_message_text), std::move(message_media), dialog_id,
true /*likely ignored*/, UserId() /*likely ignored*/, nullptr /*ignored*/); true /*likely ignored*/, UserId() /*likely ignored*/, nullptr /*ignored*/);
if (new_content->get_type() != MessageContentType::Text) { if (new_content->get_type() != MessageContentType::Text) {

View File

@ -25,7 +25,6 @@
#include "td/telegram/FullMessageId.h" #include "td/telegram/FullMessageId.h"
#include "td/telegram/Global.h" #include "td/telegram/Global.h"
#include "td/telegram/MessageContentType.h" #include "td/telegram/MessageContentType.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/MessageId.h" #include "td/telegram/MessageId.h"
#include "td/telegram/MessagesDb.h" #include "td/telegram/MessagesDb.h"
#include "td/telegram/net/NetQuery.h" #include "td/telegram/net/NetQuery.h"