From 8539d43951b299214fde925d20759be199b42852 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 29 Jan 2020 02:05:12 +0300 Subject: [PATCH] Silence warning about wrong message entities for messages from albums. GitOrigin-RevId: 13a60e258ab6aae8c80d5ea4cd8bb7037f56985c --- td/telegram/MessageContent.cpp | 6 +++--- td/telegram/MessageEntity.cpp | 4 ++-- td/telegram/MessageEntity.h | 2 +- td/telegram/MessagesManager.cpp | 11 ++++++----- td/telegram/MessagesManager.h | 1 - 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 330eb25e9..b31f22912 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -1330,9 +1330,9 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id, } case telegram_api::botInlineMessageMediaAuto::ID: { auto input_message_media_auto = move_tl_object_as(inline_message); - auto caption = - get_message_text(td->contacts_manager_.get(), input_message_media_auto->message_, - std::move(input_message_media_auto->entities_), true, 0, "register_inline_message_content"); + auto caption = get_message_text(td->contacts_manager_.get(), input_message_media_auto->message_, + std::move(input_message_media_auto->entities_), true, 0, false, + "register_inline_message_content"); if (allowed_media_content_id == td_api::inputMessageAnimation::ID) { result.message_content = make_unique(file_id, std::move(caption)); } else if (allowed_media_content_id == td_api::inputMessageAudio::ID) { diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index 2a7c2b599..49fc9962e 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -2679,13 +2679,13 @@ Status fix_formatted_text(string &text, vector &entities, bool al FormattedText get_message_text(const ContactsManager *contacts_manager, string message_text, vector> &&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 debug_message_text = message_text; auto debug_entities = entities; auto status = fix_formatted_text(message_text, entities, true, skip_new_entities, true, false); 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 \"" << debug_message_text << "\" -> \"" << message_text << "\" sent at " << send_date << " with entities " << format::as_array(debug_entities) << " -> " << format::as_array(entities); diff --git a/td/telegram/MessageEntity.h b/td/telegram/MessageEntity.h index 666302c76..7fbadf171 100644 --- a/td/telegram/MessageEntity.h +++ b/td/telegram/MessageEntity.h @@ -169,7 +169,7 @@ Status fix_formatted_text(string &text, vector &entities, bool al FormattedText get_message_text(const ContactsManager *contacts_manager, string message_text, vector> &&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 extract_input_caption( tl_object_ptr &input_message_content); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 2cbc9aadd..75f562514 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -26,6 +26,7 @@ #include "td/telegram/logevent/LogEvent.h" #include "td/telegram/logevent/LogEventHelper.h" #include "td/telegram/MessageContent.h" +#include "td/telegram/MessageEntity.h" #include "td/telegram/MessageEntity.hpp" #include "td/telegram/MessagesDb.h" #include "td/telegram/misc.h" @@ -5444,7 +5445,7 @@ void MessagesManager::on_update_service_notification(tl_object_ptrinbox_date_ : G()->unix_time(); auto message_text = 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( td_, std::move(message_text), std::move(update->media_), 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_, 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, - 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, &message_info.ttl); 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()); CHECK(old_message_text != nullptr); - FormattedText new_message_text = - get_message_text(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"); + FormattedText new_message_text = get_message_text( + td_->contacts_manager_.get(), old_message_text->text, std::move(entities), true, + 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, true /*likely ignored*/, UserId() /*likely ignored*/, nullptr /*ignored*/); if (new_content->get_type() != MessageContentType::Text) { diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 53e4dfcaf..28d4bd2cd 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -25,7 +25,6 @@ #include "td/telegram/FullMessageId.h" #include "td/telegram/Global.h" #include "td/telegram/MessageContentType.h" -#include "td/telegram/MessageEntity.h" #include "td/telegram/MessageId.h" #include "td/telegram/MessagesDb.h" #include "td/telegram/net/NetQuery.h"