From 1362f0bd0a032c2f6381d7d35f1e3ba31e28bf6f Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 21 Sep 2018 10:34:15 +0300 Subject: [PATCH] Make ContactsManager::get_current_state const. GitOrigin-RevId: b86cb9e05bed37fff06c77f235fc3039c8626334 --- td/telegram/ContactsManager.cpp | 18 +++++++++++++++--- td/telegram/ContactsManager.h | 7 ++++++- td/telegram/Td.cpp | 3 +++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 74b2a52ee..614466895 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -9630,6 +9630,11 @@ tl_object_ptr ContactsManager::get_basic_group_object(ChatId if (chat->migrated_to_channel_id.is_valid()) { get_channel_force(chat->migrated_to_channel_id); } + return get_basic_group_object_const(chat_id, chat); +} + +tl_object_ptr ContactsManager::get_basic_group_object_const(ChatId chat_id, + const Chat *chat) const { return make_tl_object( chat_id.get(), chat->participant_count, get_chat_status(chat).get_chat_member_status_object(), chat->everyone_is_administrator, chat->is_active, @@ -9731,6 +9736,11 @@ tl_object_ptr ContactsManager::get_secret_chat_object(Secret return nullptr; } get_user_force(secret_chat->user_id); + return get_secret_chat_object_const(secret_chat_id, secret_chat); +} + +tl_object_ptr ContactsManager::get_secret_chat_object_const(SecretChatId secret_chat_id, + const SecretChat *secret_chat) const { return td_api::make_object( secret_chat_id.get(), get_user_id_object(secret_chat->user_id, "secretChat"), get_secret_chat_state_object(secret_chat->state), secret_chat->is_outbound, secret_chat->ttl, @@ -9859,7 +9869,7 @@ UserId ContactsManager::get_support_user(Promise &&promise) { return UserId(); } -void ContactsManager::get_current_state(vector> &updates) { +void ContactsManager::get_current_state(vector> &updates) const { for (auto &it : users_) { updates.push_back(td_api::make_object(get_user_object(it.first, &it.second))); } @@ -9867,10 +9877,12 @@ void ContactsManager::get_current_state(vector(get_supergroup_object(it.first, &it.second))); } for (auto &it : chats_) { // chat object can contain channel_id, so it must be sent after channels - updates.push_back(td_api::make_object(get_basic_group_object(it.first, &it.second))); + updates.push_back( + td_api::make_object(get_basic_group_object_const(it.first, &it.second))); } for (auto &it : secret_chats_) { // secret chat object contains user_id, so it must be sent after users - updates.push_back(td_api::make_object(get_secret_chat_object(it.first, &it.second))); + updates.push_back( + td_api::make_object(get_secret_chat_object_const(it.first, &it.second))); } for (auto &it : users_full_) { diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index a9f8c8c0b..1200bbcbc 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -433,7 +433,7 @@ class ContactsManager : public Actor { UserId get_support_user(Promise &&promise); - void get_current_state(vector> &updates); + void get_current_state(vector> &updates) const; private: enum class LinkState : uint8 { Unknown, None, KnowsPhoneNumber, Contact }; @@ -984,6 +984,8 @@ class ContactsManager : public Actor { tl_object_ptr get_basic_group_object(ChatId chat_id, const Chat *chat); + tl_object_ptr get_basic_group_object_const(ChatId chat_id, const Chat *chat) const; + tl_object_ptr get_basic_group_full_info_object(const ChatFull *chat_full) const; tl_object_ptr get_supergroup_object(ChannelId channel_id, const Channel *channel) const; @@ -994,6 +996,9 @@ class ContactsManager : public Actor { tl_object_ptr get_secret_chat_object(SecretChatId secret_chat_id, const SecretChat *secret_chat); + tl_object_ptr get_secret_chat_object_const(SecretChatId secret_chat_id, + const SecretChat *secret_chat) const; + void delete_chat_participant(ChatId chat_id, UserId user_id, Promise &&promise); void change_channel_participant_status_impl(ChannelId channel_id, UserId user_id, DialogParticipantStatus status, diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index e77ca67b1..d86c801d6 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -4608,6 +4608,9 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) { stickers_manager_->get_current_state(updates); messages_manager_->get_current_state(updates); + + // TODO updateFileGenerationStart generation_id:int64 original_path:string destination_path:string conversion:string = Update; + // TODO updateCall call:call = Update; } auto update_terms_of_service = get_update_terms_of_service_object();