Support updateBusinessConnection in getCurrentState.

This commit is contained in:
levlam 2024-03-18 22:01:50 +03:00
parent 4219c62ee2
commit facb3a43e5
3 changed files with 20 additions and 3 deletions

View File

@ -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<td_api::updateBusinessConnection>(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<td_api::updateBusinessConnection> BusinessConnectionManager::get_update_business_connection(
const BusinessConnection *connection) const {
return td_api::make_object<td_api::updateBusinessConnection>(connection->get_business_connection_object(td_));
}
void BusinessConnectionManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
business_connections_.foreach([&](const BusinessConnectionId &business_connection_id,
const unique_ptr<BusinessConnection> &business_connection) {
updates.push_back(get_update_business_connection(business_connection.get()));
});
}
} // namespace td

View File

@ -71,6 +71,8 @@ class BusinessConnectionManager final : public Actor {
vector<td_api::object_ptr<td_api::InputMessageContent>> &&input_message_contents,
Promise<td_api::object_ptr<td_api::businessMessages>> &&promise);
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &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<telegram_api::Updates> &&updates_ptr,
Promise<td_api::object_ptr<td_api::businessMessages>> &&promise);
td_api::object_ptr<td_api::updateBusinessConnection> get_update_business_connection(
const BusinessConnection *connection) const;
WaitFreeHashMap<BusinessConnectionId, unique_ptr<BusinessConnection>, BusinessConnectionIdHash> business_connections_;
FlatHashMap<BusinessConnectionId, vector<Promise<td_api::object_ptr<td_api::businessConnection>>>,

View File

@ -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;