Make ContactsManager::get_current_state const.

GitOrigin-RevId: b86cb9e05bed37fff06c77f235fc3039c8626334
This commit is contained in:
levlam 2018-09-21 10:34:15 +03:00
parent e086b4f740
commit 1362f0bd0a
3 changed files with 24 additions and 4 deletions

View File

@ -9630,6 +9630,11 @@ tl_object_ptr<td_api::basicGroup> 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<td_api::basicGroup> ContactsManager::get_basic_group_object_const(ChatId chat_id,
const Chat *chat) const {
return make_tl_object<td_api::basicGroup>(
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<td_api::secretChat> 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<td_api::secretChat> ContactsManager::get_secret_chat_object_const(SecretChatId secret_chat_id,
const SecretChat *secret_chat) const {
return td_api::make_object<td_api::secretChat>(
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<Unit> &&promise) {
return UserId();
}
void ContactsManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) {
void ContactsManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
for (auto &it : users_) {
updates.push_back(td_api::make_object<td_api::updateUser>(get_user_object(it.first, &it.second)));
}
@ -9867,10 +9877,12 @@ void ContactsManager::get_current_state(vector<td_api::object_ptr<td_api::Update
updates.push_back(td_api::make_object<td_api::updateSupergroup>(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<td_api::updateBasicGroup>(get_basic_group_object(it.first, &it.second)));
updates.push_back(
td_api::make_object<td_api::updateBasicGroup>(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<td_api::updateSecretChat>(get_secret_chat_object(it.first, &it.second)));
updates.push_back(
td_api::make_object<td_api::updateSecretChat>(get_secret_chat_object_const(it.first, &it.second)));
}
for (auto &it : users_full_) {

View File

@ -433,7 +433,7 @@ class ContactsManager : public Actor {
UserId get_support_user(Promise<Unit> &&promise);
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates);
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
private:
enum class LinkState : uint8 { Unknown, None, KnowsPhoneNumber, Contact };
@ -984,6 +984,8 @@ class ContactsManager : public Actor {
tl_object_ptr<td_api::basicGroup> get_basic_group_object(ChatId chat_id, const Chat *chat);
tl_object_ptr<td_api::basicGroup> get_basic_group_object_const(ChatId chat_id, const Chat *chat) const;
tl_object_ptr<td_api::basicGroupFullInfo> get_basic_group_full_info_object(const ChatFull *chat_full) const;
tl_object_ptr<td_api::supergroup> get_supergroup_object(ChannelId channel_id, const Channel *channel) const;
@ -994,6 +996,9 @@ class ContactsManager : public Actor {
tl_object_ptr<td_api::secretChat> get_secret_chat_object(SecretChatId secret_chat_id, const SecretChat *secret_chat);
tl_object_ptr<td_api::secretChat> 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<Unit> &&promise);
void change_channel_participant_status_impl(ChannelId channel_id, UserId user_id, DialogParticipantStatus status,

View File

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