From facb3a43e5b9ec3dbaa8f3c87478a8347fa861ff Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 18 Mar 2024 22:01:50 +0300 Subject: [PATCH] Support updateBusinessConnection in getCurrentState. --- td/telegram/BusinessConnectionManager.cpp | 16 +++++++++++++--- td/telegram/BusinessConnectionManager.h | 5 +++++ td/telegram/Td.cpp | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/td/telegram/BusinessConnectionManager.cpp b/td/telegram/BusinessConnectionManager.cpp index 898dc51ab..9f899e774 100644 --- a/td/telegram/BusinessConnectionManager.cpp +++ b/td/telegram/BusinessConnectionManager.cpp @@ -481,9 +481,7 @@ void BusinessConnectionManager::on_update_bot_business_connect( auto &stored_connection = business_connections_[business_connection->connection_id_]; stored_connection = std::move(business_connection); - send_closure( - G()->td(), &Td::send_update, - td_api::make_object(stored_connection->get_business_connection_object(td_))); + send_closure(G()->td(), &Td::send_update, get_update_business_connection(stored_connection.get())); } void BusinessConnectionManager::on_update_bot_new_business_message( @@ -1104,4 +1102,16 @@ void BusinessConnectionManager::process_sent_business_message_album( promise.set_value(std::move(messages)); } +td_api::object_ptr BusinessConnectionManager::get_update_business_connection( + const BusinessConnection *connection) const { + return td_api::make_object(connection->get_business_connection_object(td_)); +} + +void BusinessConnectionManager::get_current_state(vector> &updates) const { + business_connections_.foreach([&](const BusinessConnectionId &business_connection_id, + const unique_ptr &business_connection) { + updates.push_back(get_update_business_connection(business_connection.get())); + }); +} + } // namespace td diff --git a/td/telegram/BusinessConnectionManager.h b/td/telegram/BusinessConnectionManager.h index 435dd5302..5e9d2e261 100644 --- a/td/telegram/BusinessConnectionManager.h +++ b/td/telegram/BusinessConnectionManager.h @@ -71,6 +71,8 @@ class BusinessConnectionManager final : public Actor { vector> &&input_message_contents, Promise> &&promise); + void get_current_state(vector> &updates) const; + private: static constexpr size_t MAX_GROUPED_MESSAGES = 10; // server side limit @@ -155,6 +157,9 @@ class BusinessConnectionManager final : public Actor { void process_sent_business_message_album(telegram_api::object_ptr &&updates_ptr, Promise> &&promise); + td_api::object_ptr get_update_business_connection( + const BusinessConnection *connection) const; + WaitFreeHashMap, BusinessConnectionIdHash> business_connections_; FlatHashMap>>, diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 919ba8144..611721253 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -4361,6 +4361,8 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) { account_manager_->get_current_state(updates); + business_connection_manager_->get_current_state(updates); + // TODO updateFileGenerationStart generation_id:int64 original_path:string destination_path:string conversion:string = Update; // TODO updateCall call:call = Update; // TODO updateGroupCall call:groupCall = Update;