From 0edd5b1651469acf1a0ac67db5cab2ec0cac4ea9 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 25 Jul 2023 14:12:58 +0300 Subject: [PATCH] Support "CHANNEL_INVALID" errors in response to channels.getDifference. --- td/telegram/MessagesManager.cpp | 14 ++++++++------ td/telegram/MessagesManager.h | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index db7edae13..d07de297f 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -4519,7 +4519,7 @@ class GetChannelDifferenceQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td_->messages_manager_->on_get_channel_difference(dialog_id_, pts_, limit_, result_ptr.move_as_ok()); + td_->messages_manager_->on_get_channel_difference(dialog_id_, pts_, limit_, result_ptr.move_as_ok(), Status::OK()); } void on_error(Status status) final { @@ -4528,7 +4528,7 @@ class GetChannelDifferenceQuery final : public Td::ResultHandler { LOG(ERROR) << "Receive error for GetChannelDifferenceQuery for " << dialog_id_ << " with PTS " << pts_ << " and limit " << limit_ << ": " << status; } - td_->messages_manager_->on_get_channel_difference(dialog_id_, pts_, limit_, nullptr); + td_->messages_manager_->on_get_channel_difference(dialog_id_, pts_, limit_, nullptr, std::move(status)); } }; @@ -38666,9 +38666,9 @@ void MessagesManager::retry_get_channel_difference_later(DialogId dialog_id) { } } -void MessagesManager::on_get_channel_difference( - DialogId dialog_id, int32 request_pts, int32 request_limit, - tl_object_ptr &&difference_ptr) { +void MessagesManager::on_get_channel_difference(DialogId dialog_id, int32 request_pts, int32 request_limit, + tl_object_ptr &&difference_ptr, + Status &&status) { get_channel_difference_count_--; CHECK(get_channel_difference_count_ >= 0); process_pending_get_channel_differences(); @@ -38680,7 +38680,8 @@ void MessagesManager::on_get_channel_difference( auto d = get_dialog_force(dialog_id, "on_get_channel_difference"); if (difference_ptr == nullptr) { - bool have_access = have_input_peer(dialog_id, AccessRights::Read); + CHECK(status.is_error()); + bool have_access = have_input_peer(dialog_id, AccessRights::Read) && status.error().message() != "CHANNEL_INVALID"; if (have_access) { if (d == nullptr) { force_create_dialog(dialog_id, "on_get_channel_difference failed"); @@ -38695,6 +38696,7 @@ void MessagesManager::on_get_channel_difference( } return; } + CHECK(status.is_ok()); LOG(INFO) << "Receive result of getChannelDifference for " << dialog_id << " with PTS = " << request_pts << " and limit = " << request_limit << " from " << source << ": " << to_string(difference_ptr); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 0cbedbf04..edb681cc9 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -969,7 +969,8 @@ class MessagesManager final : public Actor { void on_create_new_dialog_fail(int64 random_id, Status error, Promise &&promise); void on_get_channel_difference(DialogId dialog_id, int32 request_pts, int32 request_limit, - tl_object_ptr &&difference_ptr); + tl_object_ptr &&difference_ptr, + Status &&status); void try_update_dialog_pos(DialogId dialog_id);