From c7b9d54fdbd85b5afe59c46be8c7beb3cccfb64c Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 15 May 2023 11:47:05 +0300 Subject: [PATCH] Fix inputChannelFromMessage support. --- td/telegram/ContactsManager.cpp | 12 +++++++----- td/telegram/MessagesManager.cpp | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 93650b6c8..3f658513f 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -3479,6 +3479,9 @@ class GetChannelsQuery final : public Td::ResultHandler { CHECK(input_channel != nullptr); if (input_channel->get_id() == telegram_api::inputChannel::ID) { channel_id_ = ChannelId(static_cast(input_channel.get())->channel_id_); + } else if (input_channel->get_id() == telegram_api::inputChannelFromMessage::ID) { + channel_id_ = + ChannelId(static_cast(input_channel.get())->channel_id_); } vector> input_channels; @@ -14084,8 +14087,7 @@ bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &s auto c = get_channel(channel_id); if (c == nullptr) { - if (Slice(source) == Slice("GetChannelDifferenceQuery") || - (td_->auth_manager_->is_bot() && Slice(source) == Slice("GetChannelsQuery"))) { + if (Slice(source) == Slice("GetChannelDifferenceQuery") || Slice(source) == Slice("GetChannelsQuery")) { // get channel difference after restart // get channel from server by its identifier return true; @@ -18034,10 +18036,10 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat, const char *sourc ChannelId migrated_to_channel_id; if (chat.flags_ & CHAT_FLAG_WAS_MIGRATED) { switch (chat.migrated_to_->get_id()) { - case telegram_api::inputChannelEmpty::ID: { - LOG(ERROR) << "Receive empty upgraded to supergroup for " << chat_id << debug_str; + case telegram_api::inputChannelFromMessage::ID: + case telegram_api::inputChannelEmpty::ID: + LOG(ERROR) << "Receive invalid information about upgraded supergroup for " << chat_id << debug_str; break; - } case telegram_api::inputChannel::ID: { auto input_channel = move_tl_object_as(chat.migrated_to_); migrated_to_channel_id = ChannelId(input_channel->channel_id_); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 5273285ff..bd6f0b257 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -37993,9 +37993,9 @@ void MessagesManager::get_channel_difference(DialogId dialog_id, int32 pts, bool return; } - if (force && get_channel_difference_to_log_event_id_.count(dialog_id) == 0 && !td_->ignore_background_updates()) { + if (force && get_channel_difference_to_log_event_id_.count(dialog_id) == 0 && !td_->ignore_background_updates() && + input_channel->get_id() == telegram_api::inputChannel::ID) { auto channel_id = dialog_id.get_channel_id(); - CHECK(input_channel->get_id() == telegram_api::inputChannel::ID); auto access_hash = static_cast(*input_channel).access_hash_; auto log_event = GetChannelDifferenceLogEvent(channel_id, access_hash); auto log_event_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::GetChannelDifference,